diff --git a/default.nix b/default.nix index 77981c6..461244a 100644 --- a/default.nix +++ b/default.nix @@ -16,7 +16,7 @@ hostSystem = buildSystem; }; - garageNix = (import ./nix/garage.nix); + garageNix = (import ./nix/garage); in rec { @@ -80,11 +80,9 @@ in rec { garage = let hostPlatform = pkgs.stdenv.hostPlatform.parsed; - in pkgs.callPackage garageNix.package { - inherit buildSystem; + in garageNix.package { + inherit pkgsNix buildSystem; hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl"; - pkgsSrc = pkgsNix.src; - }; appDirBase = pkgs.buildEnv { diff --git a/nix/garage/common-nix-system.patch b/nix/garage/common-nix-system.patch new file mode 100644 index 0000000..d310669 --- /dev/null +++ b/nix/garage/common-nix-system.patch @@ -0,0 +1,21 @@ +diff --git a/nix/common.nix b/nix/common.nix +index 1ad809bb..47a92038 100644 +--- a/nix/common.nix ++++ b/nix/common.nix +@@ -1,4 +1,6 @@ +-let ++{ ++ system ? builtins.currentSystem, ++}: let + lock = builtins.fromJSON (builtins.readFile ../flake.lock); + + inherit (lock.nodes.flake-compat.locked) owner repo rev narHash; +@@ -8,7 +10,7 @@ let + sha256 = narHash; + }; + +- flake = (import flake-compat { system = builtins.currentSystem; src = ../.; }); ++ flake = (import flake-compat { inherit system; src = ../.; }); + in + rec { + pkgsSrc = flake.defaultNix.inputs.nixpkgs; diff --git a/nix/garage.nix b/nix/garage/default.nix similarity index 52% rename from nix/garage.nix rename to nix/garage/default.nix index 2ebe030..b08bd9f 100644 --- a/nix/garage.nix +++ b/nix/garage/default.nix @@ -2,25 +2,39 @@ rec { version = "1.0.0"; - src = builtins.fetchGit { - name = "garage-v${version}"; - url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git"; - rev = "ff093ddbb8485409f389abe7b5e569cb38d222d2"; - }; - package = { - pkgsSrc, + pkgsNix, buildSystem, hostSystem, }: let + pkgs = pkgsNix.default { + inherit buildSystem hostSystem; + }; + + src = pkgs.applyPatches { + name = "garage-v${version}-patched"; + src = builtins.fetchGit { + name = "garage-v${version}"; + url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git"; + rev = "ff093ddbb8485409f389abe7b5e569cb38d222d2"; + }; + patches = [ + ./common-nix-system.patch + ]; + }; + + common = (import "${src}/nix/common.nix") { + system = buildSystem; + }; + compile = (import "${src}/nix/compile.nix") { system = buildSystem; target = hostSystem; - pkgsSrc = pkgsSrc; + pkgsSrc = pkgsNix.src; - cargo2nixOverlay = (import "${src}/nix/common.nix").cargo2nixOverlay; + cargo2nixOverlay = common.cargo2nixOverlay; release = true; git_version = version; diff --git a/tasks/v0.0.3/code/fix-nix-flake.nix b/tasks/v0.0.3/code/fix-nix-flake.nix deleted file mode 100644 index 2513f4d..0000000 --- a/tasks/v0.0.3/code/fix-nix-flake.nix +++ /dev/null @@ -1,8 +0,0 @@ ---- -type: task ---- - -# Fix `flake.nix` - -The `flake.nix` file is currently broken, garage is using -`builtins.currentSystem` for some reason.