diff --git a/default.nix b/default.nix index 8ddc0af8..9d8508d9 100644 --- a/default.nix +++ b/default.nix @@ -1,48 +1,28 @@ -{ system ? builtins.currentSystem, git_version ? null, }: +{ system ? builtins.currentSystem, git_version ? "unknown", }: with import ./nix/common.nix; let - pkgs = import pkgsSrc { }; + pkgs = import nixpkgs { }; compile = import ./nix/compile.nix; - build_debug_and_release = (target: { - debug = (compile { - inherit system target git_version pkgsSrc cargo2nixOverlay; - release = false; - }).workspace.garage { compileMode = "build"; }; + compileWith = args: compile ({ + inherit system git_version nixpkgs; + crane = flake.inputs.crane; + rust-overlay = flake.inputs.rust-overlay; + } // args); - release = (compile { - inherit system target git_version pkgsSrc cargo2nixOverlay; - release = true; - }).workspace.garage { compileMode = "build"; }; - }); - - test = (rustPkgs: - pkgs.symlinkJoin { - name = "garage-tests"; - paths = - builtins.map (key: rustPkgs.workspace.${key} { compileMode = "test"; }) - (builtins.attrNames rustPkgs.workspace); - }); + build_release = target: (compile { + inherit target; + release = true; + }).garage; in { - pkgs = { - amd64 = build_debug_and_release "x86_64-unknown-linux-musl"; - i386 = build_debug_and_release "i686-unknown-linux-musl"; - arm64 = build_debug_and_release "aarch64-unknown-linux-musl"; - arm = build_debug_and_release "armv6l-unknown-linux-musleabihf"; - }; - test = { - amd64 = test (compile { - inherit system git_version pkgsSrc cargo2nixOverlay; - target = "x86_64-unknown-linux-musl"; - features = [ - "garage/bundled-libs" - "garage/k2v" - "garage/lmdb" - "garage/sqlite" - ]; - }); + releasePackages = { + amd64 = build_release "x86_64-unknown-linux-musl"; + i386 = build_release "i686-unknown-linux-musl"; + arm64 = build_release "aarch64-unknown-linux-musl"; + arm = build_release "armv6l-unknown-linux-musleabihf"; }; + flakePackages = flake.packages.${system}; } diff --git a/nix/common.nix b/nix/common.nix index 1ad809bb..2c03f04e 100644 --- a/nix/common.nix +++ b/nix/common.nix @@ -10,9 +10,9 @@ let flake = (import flake-compat { system = builtins.currentSystem; src = ../.; }); in -rec { - pkgsSrc = flake.defaultNix.inputs.nixpkgs; - cargo2nix = flake.defaultNix.inputs.cargo2nix; - cargo2nixOverlay = cargo2nix.overlays.default; - devShells = builtins.getAttr builtins.currentSystem flake.defaultNix.devShells; + +{ + flake = flake.defaultNix; + nixpkgs = flake.defaultNix.inputs.nixpkgs; + devShells = flake.defaultNix.devShells.${builtins.currentSystem}; } diff --git a/shell.nix b/shell.nix index cc06f0fb..ab0bc71f 100644 --- a/shell.nix +++ b/shell.nix @@ -3,7 +3,7 @@ with import ./nix/common.nix; let - pkgs = import pkgsSrc { + pkgs = import nixpkgs { inherit system; }; winscp = (import ./nix/winscp.nix) pkgs;