Compare commits

..

No commits in common. "7ca272b612c194747402931381dce8328c0d07a0" and "c8854fcbd489264fe82937c100495c6e8ceb71e6" have entirely different histories.

3 changed files with 16 additions and 201 deletions

View file

@ -1,44 +0,0 @@
{ system, target ? null, pkgsSrc, cargo2nixOverlay, compiler ? "rustc",
release ? false, }:
let
pkgs = if target != null then
import pkgsSrc {
inherit system;
crossSystem = {
config = target;
isStatic = true;
};
overlays = [ cargo2nixOverlay ];
}
else
import pkgsSrc {
inherit system;
overlays = [ cargo2nixOverlay ];
};
toolchainOptions = {
rustVersion = "1.75.0";
};
packageFun = import ./Cargo.nix;
codegenOpts = {
"armv6l-unknown-linux-musleabihf" = [
"target-feature=+crt-static"
"link-arg=-static"
]; # compile as dynamic with static-pie
"x86_64-unknown-linux-musl" =
[ "target-feature=+crt-static" "link-arg=-static-pie" ];
};
# NixOS and Rust/Cargo triples do not match for ARM, fix it here.
rustTarget = if target == "armv6l-unknown-linux-musleabihf" then
"arm-unknown-linux-musleabihf"
else
target;
in pkgs.rustBuilder.makePackageSet ({
inherit release packageFun codegenOpts;
target = rustTarget;
} // toolchainOptions)

View file

@ -1,130 +0,0 @@
{
"nodes": {
"cargo2nix": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1705129117,
"narHash": "sha256-LgdDHibvimzYhxBK3kxCk2gAL7k4Hyigl5KI0X9cijA=",
"owner": "cargo2nix",
"repo": "cargo2nix",
"rev": "ae19a9e1f8f0880c088ea155ab66cee1fa001f59",
"type": "github"
},
"original": {
"owner": "cargo2nix",
"ref": "release-0.11.0",
"repo": "cargo2nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1720535198,
"narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"cargo2nix": "cargo2nix",
"flake-utils": [
"cargo2nix",
"flake-utils"
],
"nixpkgs": "nixpkgs"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"cargo2nix",
"flake-utils"
],
"nixpkgs": [
"cargo2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1705112162,
"narHash": "sha256-IAM0+Uijh/fwlfoeDrOwau9MxcZW3zeDoUHc6Z3xfqM=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "9e0af26ffe52bf955ad5575888f093e41fba0104",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -10,36 +10,25 @@
}; };
outputs = { self, nixpkgs, cargo2nix, flake-utils }: outputs = { self, nixpkgs, cargo2nix, flake-utils }:
let
compile = import ./compile.nix;
in
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = import nixpkgs {
in inherit system;
rec { overlays = [cargo2nix.overlays.default];
packages = };
let
packageFor = target: (compile { rustPkgs = pkgs.rustBuilder.makePackageSet {
inherit system target; rustVersion = "1.75.0";
pkgsSrc = nixpkgs; packageFun = import ./Cargo.nix;
cargo2nixOverlay = cargo2nix.overlays.default; };
release = true;
}).workspace.restic-alarm { compileMode = "build"; }; in rec {
in packages = {
{ restic-alarm = (rustPkgs.workspace.restic-alarm {});
# default = native release build
default = packages.restic-alarm; default = packages.restic-alarm;
restic-alarm = packageFor null;
# other = cross-compiled, statically-linked builds
amd64 = packageFor "x86_64-unknown-linux-musl";
i386 = packageFor "i686-unknown-linux-musl";
arm64 = packageFor "aarch64-unknown-linux-musl";
arm = packageFor "armv6l-unknown-linux-musleabihf";
}; };
} }
) ) // rec {
// rec {
nixosModules.restic-alarm = { config, lib, pkgs, ... }: nixosModules.restic-alarm = { config, lib, pkgs, ... }:
with lib; with lib;
let let