From 6aa14bb57ca6eb324e9dda64f169daf2495f04b2 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 15 Dec 2024 15:33:47 +0100 Subject: [PATCH] Fix building via nix flake --- default.nix | 8 +++---- nix/garage/common-nix-system.patch | 21 +++++++++++++++++ nix/{garage.nix => garage/default.nix} | 32 ++++++++++++++++++-------- tasks/v0.0.3/code/fix-nix-flake.nix | 8 ------- 4 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 nix/garage/common-nix-system.patch rename nix/{garage.nix => garage/default.nix} (52%) delete mode 100644 tasks/v0.0.3/code/fix-nix-flake.nix 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.