Fix building via nix flake

This commit is contained in:
Brian Picciano 2024-12-15 15:33:47 +01:00
parent 886f76fe0b
commit 6aa14bb57c
4 changed files with 47 additions and 22 deletions

View File

@ -16,7 +16,7 @@
hostSystem = buildSystem; hostSystem = buildSystem;
}; };
garageNix = (import ./nix/garage.nix); garageNix = (import ./nix/garage);
in rec { in rec {
@ -80,11 +80,9 @@ in rec {
garage = let garage = let
hostPlatform = pkgs.stdenv.hostPlatform.parsed; hostPlatform = pkgs.stdenv.hostPlatform.parsed;
in pkgs.callPackage garageNix.package { in garageNix.package {
inherit buildSystem; inherit pkgsNix buildSystem;
hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl"; hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl";
pkgsSrc = pkgsNix.src;
}; };
appDirBase = pkgs.buildEnv { appDirBase = pkgs.buildEnv {

View File

@ -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;

View File

@ -2,25 +2,39 @@ rec {
version = "1.0.0"; version = "1.0.0";
package = {
pkgsNix,
buildSystem,
hostSystem,
}: let
pkgs = pkgsNix.default {
inherit buildSystem hostSystem;
};
src = pkgs.applyPatches {
name = "garage-v${version}-patched";
src = builtins.fetchGit { src = builtins.fetchGit {
name = "garage-v${version}"; name = "garage-v${version}";
url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git"; url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git";
rev = "ff093ddbb8485409f389abe7b5e569cb38d222d2"; rev = "ff093ddbb8485409f389abe7b5e569cb38d222d2";
}; };
patches = [
./common-nix-system.patch
];
};
package = { common = (import "${src}/nix/common.nix") {
pkgsSrc, system = buildSystem;
buildSystem, };
hostSystem,
}: let
compile = (import "${src}/nix/compile.nix") { compile = (import "${src}/nix/compile.nix") {
system = buildSystem; system = buildSystem;
target = hostSystem; target = hostSystem;
pkgsSrc = pkgsSrc; pkgsSrc = pkgsNix.src;
cargo2nixOverlay = (import "${src}/nix/common.nix").cargo2nixOverlay; cargo2nixOverlay = common.cargo2nixOverlay;
release = true; release = true;
git_version = version; git_version = version;

View File

@ -1,8 +0,0 @@
---
type: task
---
# Fix `flake.nix`
The `flake.nix` file is currently broken, garage is using
`builtins.currentSystem` for some reason.