Files
roowho2/flake.nix
h7x4 6b94e42ed4
Some checks failed
Build and test / check (push) Successful in 1m6s
Build and test / build (push) Failing after 1m29s
Build and test / test (push) Failing after 1m50s
Build and test / docs (push) Successful in 2m52s
Cargo.toml: enable uucore logind integration, add systemd compile flag
2026-01-09 15:42:05 +09:00

106 lines
2.8 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, rust-overlay}:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
"armv7l-linux"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
];
};
rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages;
toolchain = rust-bin.nightly.latest.default.override {
extensions = [ "rust-src" ];
};
in f system pkgs toolchain);
in {
apps = let
mkApp = program: description: {
type = "app";
program = toString program;
meta = {
inherit description;
};
};
mkVm = name: mkApp "${self.nixosConfigurations.${name}.config.system.build.vm}/bin/run-nixos-vm";
in forAllSystems (system: pkgs: _: {
vm = mkVm "vm" "Start a NixOS VM with roowho2 installed";
});
nixosConfigurations = {
vm = import ./nix/vm.nix { inherit self nixpkgs; };
};
devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell {
nativeBuildInputs = with pkgs; [
toolchain
cargo-edit
] ++ (lib.optionals stdenv.buildPlatform.isLinux [
systemdLibs
]);
env = {
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
RUSTFLAGS = "-Zhigher-ranked-assumptions";
CARGO_CFG_FEATURE = lib.concatStringsSep "," (lib.optionals pkgs.stdenv.buildPlatform.isLinux [
"systemd"
]);
};
});
overlays = {
default = self.overlays.roowho2;
roowho2 = final: prev: {
inherit (self.packages.${prev.stdenv.hostPlatform.system}) roowho2;
};
};
nixosModules.default = ./nix/module.nix;
packages = forAllSystems (system: pkgs: _:
let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
cargoLock = ./Cargo.lock;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./src
./Cargo.toml
./Cargo.lock
];
};
rustPlatform = pkgs.makeRustPlatform {
rustc = pkgs.rust-bin.nightly.latest.default;
cargo = pkgs.rust-bin.nightly.latest.cargo;
};
in {
default = self.packages.${system}.roowho2;
roowho2 = pkgs.callPackage ./nix/package.nix { inherit cargoToml cargoLock src rustPlatform; };
filteredSource = pkgs.runCommandLocal "filtered-source" { } ''
ln -s ${src} $out
'';
});
};
}