aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix8
-rw-r--r--flake.lock108
-rw-r--r--flake.nix28
-rw-r--r--nix/compile.nix33
-rw-r--r--shell.nix2
5 files changed, 161 insertions, 18 deletions
diff --git a/default.nix b/default.nix
index 60a85e2f..1791b3c6 100644
--- a/default.nix
+++ b/default.nix
@@ -11,14 +11,14 @@ let
build_debug_and_release = (target: {
debug = (compile {
- inherit target git_version;
+ inherit system target git_version pkgsSrc cargo2nixOverlay;
release = false;
}).workspace.garage {
compileMode = "build";
};
release = (compile {
- inherit target git_version;
+ inherit system target git_version pkgsSrc cargo2nixOverlay;
release = true;
}).workspace.garage {
compileMode = "build";
@@ -39,7 +39,7 @@ in {
};
test = {
amd64 = test (compile {
- inherit git_version;
+ inherit system git_version pkgsSrc cargo2nixOverlay;
target = "x86_64-unknown-linux-musl";
features = [
"garage/bundled-libs"
@@ -52,7 +52,7 @@ in {
};
clippy = {
amd64 = (compile {
- inherit git_version;
+ inherit system git_version pkgsSrc cargo2nixOverlay;
target = "x86_64-unknown-linux-musl";
compiler = "clippy";
}).workspace.garage {
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..4b5713dc
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,108 @@
+{
+ "nodes": {
+ "cargo2nix": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "flake-utils": "flake-utils",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "rust-overlay": "rust-overlay"
+ },
+ "locked": {
+ "lastModified": 1666087781,
+ "narHash": "sha256-trKVdjMZ8mNkGfLcY5LsJJGtdV3xJDZnMVrkFjErlcs=",
+ "owner": "Alexis211",
+ "repo": "cargo2nix",
+ "rev": "a7a61179b66054904ef6a195d8da736eaaa06c36",
+ "type": "github"
+ },
+ "original": {
+ "owner": "Alexis211",
+ "repo": "cargo2nix",
+ "rev": "a7a61179b66054904ef6a195d8da736eaaa06c36",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1650374568,
+ "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "b4a34015c698c7793d592d66adbab377907a2be8",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "locked": {
+ "lastModified": 1659877975,
+ "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1665657542,
+ "narHash": "sha256-mojxNyzbvmp8NtVtxqiHGhRfjCALLfk9i/Uup68Y5q8=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "a3073c49bc0163fea6a121c276f526837672b555",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "a3073c49bc0163fea6a121c276f526837672b555",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "cargo2nix": "cargo2nix",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "rust-overlay": {
+ "inputs": {
+ "flake-utils": [
+ "cargo2nix",
+ "flake-utils"
+ ],
+ "nixpkgs": [
+ "cargo2nix",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1664247556,
+ "narHash": "sha256-J4vazHU3609ekn7dr+3wfqPo5WGlZVAgV7jfux352L0=",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "rev": "524db9c9ea7bc7743bb74cdd45b6d46ea3fcc2ab",
+ "type": "github"
+ },
+ "original": {
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000..b862e8e6
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,28 @@
+{
+ description = "Garage, an S3-compatible distributed object store for self-hosted deployments";
+
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/a3073c49bc0163fea6a121c276f526837672b555";
+ inputs.cargo2nix = {
+ # As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection
+ url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ outputs = { self, nixpkgs, cargo2nix }: let
+ git_version = "v0.8.0-rc2";
+ compile = import ./nix/compile.nix;
+ forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
+ in
+ {
+ packages = forAllSystems (system: {
+ default = (compile {
+ inherit system git_version;
+ pkgsSrc = nixpkgs;
+ cargo2nixOverlay = cargo2nix.overlays.default;
+ release = true;
+ }).workspace.garage {
+ compileMode = "build";
+ };
+ });
+ };
+}
diff --git a/nix/compile.nix b/nix/compile.nix
index 303c3aa4..3ea5035e 100644
--- a/nix/compile.nix
+++ b/nix/compile.nix
@@ -1,25 +1,32 @@
{
- system ? builtins.currentSystem,
- target,
+ system,
+ target ? null,
+ pkgsSrc,
+ cargo2nixOverlay,
compiler ? "rustc",
release ? false,
git_version ? null,
features ? null,
}:
-with import ./common.nix;
-
let
log = v: builtins.trace v v;
- pkgs = import pkgsSrc {
- inherit system;
- crossSystem = {
- config = target;
- isStatic = true;
- };
- overlays = [ cargo2nixOverlay ];
- };
+ pkgs =
+ if target != null then
+ import pkgsSrc {
+ inherit system;
+ crossSystem = {
+ config = target;
+ isStatic = true;
+ };
+ overlays = [ cargo2nixOverlay ];
+ }
+ else
+ import pkgsSrc {
+ inherit system;
+ overlays = [ cargo2nixOverlay ];
+ };
/*
Cargo2nix is built for rustOverlay which installs Rust from Mozilla releases.
@@ -34,7 +41,7 @@ let
NixOS ships them in separate ones. We reunite them with symlinkJoin.
*/
toolchainOptions =
- if target == "x86_64-unknown-linux-musl" || target == "aarch64-unknown-linux-musl" then {
+ if target == null || target == "x86_64-unknown-linux-musl" || target == "aarch64-unknown-linux-musl" then {
rustVersion = "1.63.0";
extraRustComponents = [ "clippy" ];
} else {
diff --git a/shell.nix b/shell.nix
index 480bc349..5cece8ad 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,5 +1,5 @@
{
- system ? builtins.currentSystem,
+ system ? builtins.currentSystem,
}:
with import ./nix/common.nix;