switch from flake-utils to flake-parts
There is not so much of a difference in this project, but it means adding this project to clan is one less flake input and also more consistent with other projects in clan.
This commit is contained in:
parent
c9095421c6
commit
1315858592
2 changed files with 94 additions and 86 deletions
37
flake.lock
generated
37
flake.lock
generated
|
|
@ -1,20 +1,22 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"nixpkgs-lib": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731533236,
|
"lastModified": 1768135262,
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
"narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=",
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
"rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -36,7 +38,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
}
|
}
|
||||||
|
|
@ -60,21 +62,6 @@
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"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",
|
"root": "root",
|
||||||
|
|
|
||||||
143
flake.nix
143
flake.nix
|
|
@ -1,80 +1,101 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {self, nixpkgs, flake-utils, rust-overlay}:
|
outputs =
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
inputs@{ flake-parts, ... }:
|
||||||
let
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
overlays = [ (import rust-overlay) ];
|
systems = [
|
||||||
pkgs = import nixpkgs {
|
"x86_64-linux"
|
||||||
inherit system overlays;
|
"aarch64-linux"
|
||||||
};
|
];
|
||||||
|
|
||||||
buildEnvVars = {
|
perSystem =
|
||||||
BIN_XDG_PERMISSION_STORE = "${pkgs.xdg-desktop-portal}/libexec/xdg-permission-store";
|
{
|
||||||
BIN_XDG_DOCUMENT_PORTAL = "${pkgs.xdg-desktop-portal}/libexec/xdg-document-portal";
|
pkgs,
|
||||||
BIN_VIRTIOFSD = "${pkgs.virtiofsd}/bin/virtiofsd";
|
system,
|
||||||
};
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
overlays = [ (import inputs.rust-overlay) ];
|
||||||
|
pkgs' = import inputs.nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
|
||||||
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
buildEnvVars = {
|
||||||
rustPlatform = pkgs.makeRustPlatform {
|
BIN_XDG_PERMISSION_STORE = "${pkgs.xdg-desktop-portal}/libexec/xdg-permission-store";
|
||||||
cargo = rustToolchain;
|
BIN_XDG_DOCUMENT_PORTAL = "${pkgs.xdg-desktop-portal}/libexec/xdg-document-portal";
|
||||||
rustc = rustToolchain;
|
BIN_VIRTIOFSD = "${pkgs.virtiofsd}/bin/virtiofsd";
|
||||||
};
|
};
|
||||||
rustPackage = crate:
|
|
||||||
let cargoToml = builtins.fromTOML (builtins.readFile ./${crate}/Cargo.toml);
|
rustToolchain = pkgs'.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
in rustPlatform.buildRustPackage {
|
rustPlatform = pkgs'.makeRustPlatform {
|
||||||
inherit (cargoToml.package) name version;
|
cargo = rustToolchain;
|
||||||
src = ./.;
|
rustc = rustToolchain;
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
};
|
||||||
cargoLock.outputHashes = {
|
|
||||||
"zbus-5.9.0" = "sha256-uaHPHdmDWYy0jeKPd0/eCUupID2tswGHmEmscp6fCII=";
|
rustPackage =
|
||||||
"busd-0.4.0" = "sha256-hIvjt3v6AYc7URLFknXTmSc+NdxOlN/2RGXVsuoNgA4=";
|
crate:
|
||||||
|
let
|
||||||
|
cargoToml = builtins.fromTOML (builtins.readFile ./${crate}/Cargo.toml);
|
||||||
|
in
|
||||||
|
rustPlatform.buildRustPackage {
|
||||||
|
inherit (cargoToml.package) name version;
|
||||||
|
src = ./.;
|
||||||
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
cargoLock.outputHashes = {
|
||||||
|
"zbus-5.9.0" = "sha256-uaHPHdmDWYy0jeKPd0/eCUupID2tswGHmEmscp6fCII=";
|
||||||
|
"busd-0.4.0" = "sha256-hIvjt3v6AYc7URLFknXTmSc+NdxOlN/2RGXVsuoNgA4=";
|
||||||
|
};
|
||||||
|
buildAndTestSubdir = crate;
|
||||||
|
env = buildEnvVars;
|
||||||
};
|
};
|
||||||
buildAndTestSubdir = crate;
|
in
|
||||||
|
{
|
||||||
|
devShells.default = pkgs'.mkShell {
|
||||||
|
buildInputs = [ rustToolchain ];
|
||||||
env = buildEnvVars;
|
env = buildEnvVars;
|
||||||
};
|
};
|
||||||
in
|
|
||||||
{
|
packages.sidebus-agent = rustPackage "sidebus-agent";
|
||||||
devShells.default = pkgs.mkShell {
|
packages.sidebus-broker = rustPackage "sidebus-broker";
|
||||||
buildInputs = [ rustToolchain ];
|
|
||||||
env = buildEnvVars;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
packages.sidebus-agent = rustPackage "sidebus-agent";
|
flake = {
|
||||||
packages.sidebus-broker = rustPackage "sidebus-broker";
|
nixosModules.sidebus-vm =
|
||||||
|
{ ... }:
|
||||||
nixosModules.sidebus-vm = { ... }: {
|
{
|
||||||
environment.sessionVariables.DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/sidebus.sock";
|
environment.sessionVariables.DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/sidebus.sock";
|
||||||
systemd.sockets.sidebus-agent = {
|
systemd.sockets.sidebus-agent = {
|
||||||
# SocketMode= is 0666 by default
|
# SocketMode= is 0666 by default
|
||||||
listenStreams = [ "/run/sidebus.sock" ];
|
listenStreams = [ "/run/sidebus.sock" ];
|
||||||
wantedBy = [ "sockets.target" ];
|
wantedBy = [ "sockets.target" ];
|
||||||
documentation = [ "https://git.clan.lol/valpackett/sidebus" ];
|
documentation = [ "https://git.clan.lol/valpackett/sidebus" ];
|
||||||
};
|
|
||||||
systemd.services.sidebus-agent = {
|
|
||||||
# TODO: confinement (can do a lot)
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = "${rustPackage "sidebus-agent"}/bin/sidebus-agent";
|
|
||||||
ImportCredential = "sidebus.*";
|
|
||||||
};
|
};
|
||||||
documentation = [ "https://git.clan.lol/valpackett/sidebus" ];
|
systemd.services.sidebus-agent = {
|
||||||
|
# TODO: confinement (can do a lot)
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = throw "sidebus-vm module requires setting systemd.services.sidebus-agent.serviceConfig.ExecStart to a sidebus-agent package";
|
||||||
|
ImportCredential = "sidebus.*";
|
||||||
|
};
|
||||||
|
documentation = [ "https://git.clan.lol/valpackett/sidebus" ];
|
||||||
|
};
|
||||||
|
systemd.mounts = [
|
||||||
|
{
|
||||||
|
type = "virtiofs";
|
||||||
|
what = "vm-doc-portal";
|
||||||
|
where = "/run/vm-doc-portal";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
systemd.mounts = [
|
};
|
||||||
{
|
};
|
||||||
type = "virtiofs";
|
|
||||||
what = "vm-doc-portal";
|
|
||||||
where = "/run/vm-doc-portal";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue