diff --git a/default.nix b/default.nix index bf1f1a9..f0b952f 100644 --- a/default.nix +++ b/default.nix @@ -1,8 +1,14 @@ # TODO # - allow injecting a bootstrap file -# - Set ARCH arg for appimagetool target in default.nix +{ -let + buildSystem ? builtins.currentSystem, + hostSystem ? builtins.currentSystem, + + revision ? "", + releaseName ? "debug", + +}: let pkgsNix = (import ./nix/pkgs.nix); @@ -10,20 +16,14 @@ let inherit buildSystem hostSystem; }; -in { + garageNix = (import ./nix/garage.nix); - buildSystem ? builtins.currentSystem, - hostSystem ? builtins.currentSystem, - - selfRev ? "", - releaseName ? "debug", - -}: rec { +in rec { version = pkgs.stdenv.mkDerivation { name = "cryptic-net-version"; - inherit selfRev hostSystem releaseName; + inherit revision hostSystem releaseName; repoSrc = ./.; nativeBuildInputs = [ pkgs.git ]; @@ -31,22 +31,21 @@ in { # TODO it'd be nice to be able to call `go version`, but that doesn't work # when crossSystem is being used for some unknown reason. goVersion = pkgs.go.version; - #garageVersion = garage.version; - garageVersion = "TODO"; + garageVersion = garageNix.version; builder = builtins.toFile "builder.sh" '' source $stdenv/setup versionFile=version - if [ "$selfRev" = "" ]; then + if [ "$revision" = "" ]; then cp -r "$repoSrc" repoSrcCp - selfRev="$(cd repoSrcCp && git rev-parse HEAD)" + revision="$(cd repoSrcCp && git rev-parse HEAD)" fi echo "Release $releaseName" >> "$versionFile" echo "System: $hostSystem" >> "$versionFile" - echo "Git Revision: $selfRev" >> "$versionFile" + echo "Git Revision: $revision" >> "$versionFile" echo "Go Version: $goVersion" >> "$versionFile" echo "Garage Version: $garageVersion" >> "$versionFile" @@ -67,7 +66,7 @@ in { hostPlatform = pkgs.stdenv.hostPlatform.parsed; - in pkgs.callPackage (import ./nix/garage.nix) { + in pkgs.callPackage garageNix.package { inherit buildSystem; hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl"; @@ -100,7 +99,7 @@ in { appimagetool ]; - ARCH = "x86_64"; + ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name; builder = builtins.toFile "build.sh" '' source $stdenv/setup diff --git a/flake.nix b/flake.nix index 051f27a..0932b0a 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ defaultAttrs = (import ./default.nix) { inherit hostSystem buildSystem; - selfRev = if self ? rev then self.rev else "dirty"; + revision = if self ? rev then self.rev else "dirty"; releaseName = "flake"; }; diff --git a/nix/garage.nix b/nix/garage.nix index 252a00b..3320829 100644 --- a/nix/garage.nix +++ b/nix/garage.nix @@ -1,39 +1,33 @@ -{ - - pkgsSrc, - buildSystem, - hostSystem, - - fetchgit, - buildEnv, - minio-client, - -}: let +rec { version = "0.8.1"; - src = fetchgit { + src = builtins.fetchGit { name = "garage-v${version}"; url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git"; rev = "76230f20282e73a5a5afa33af68152acaf732cf5"; - sha256 = "sha256-lpNp/jw4YaczG3NM3pVWR0cZ8u/KBQCWvvfAswO4+Do="; }; - compiled = (import "${src}/nix/compile.nix") { + package = { + pkgsSrc, + buildSystem, + hostSystem, + }: let - system = buildSystem; - target = hostSystem; - pkgsSrc = pkgsSrc; + compile = (import "${src}/nix/compile.nix") { - cargo2nixOverlay = (import "${src}/nix/common.nix").cargo2nixOverlay; + system = buildSystem; + target = hostSystem; + pkgsSrc = pkgsSrc; - release = true; - git_version = version; + cargo2nixOverlay = (import "${src}/nix/common.nix").cargo2nixOverlay; - }; + release = true; + git_version = version; + }; -in - - compiled.workspace.garage { - compileMode = "build"; - } + in + compile.workspace.garage { + compileMode = "build"; + }; +}