selfprivacy-nixos-config/flake.nix

53 lines
1.6 KiB
Nix
Raw Normal View History

2023-07-15 12:52:46 +00:00
{
description = "Selfprivacy NixOS configuration flake";
inputs = {
2023-07-17 00:58:26 +00:00
nixpkgs.url = "github:nixos/nixpkgs";
selfprivacy-overlay.url =
2023-07-17 00:58:26 +00:00
"git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nix-repo.git";
# these inputs are expected to be set by the caller
# for example, upon nix build using --override-input
userdata-json.flake = false; # userdata.json
hardware-configuration-nix.flake = false; # hardware-configuration.nix
2023-07-15 12:52:46 +00:00
};
outputs =
{ self
, nixpkgs
, selfprivacy-overlay
, userdata-json
, hardware-configuration-nix
}:
2023-07-15 12:52:46 +00:00
let
system = "x86_64-linux";
cfgShortRev = builtins.substring 0 7 self.rev;
nixosLabel = config:
"${config.system.nixos.release}.${cfgShortRev}.${nixpkgs.shortRev}";
userdata = builtins.fromJSON (builtins.readFile userdata-json);
hardware-configuration = import hardware-configuration-nix;
2023-07-15 12:52:46 +00:00
in
{
nixosConfigurations = {
2023-07-15 12:52:46 +00:00
just-nixos = nixpkgs.lib.nixosSystem {
specialArgs = { inherit system userdata; };
modules = [
# SelfPrivacy overlay
{ nixpkgs.overlays = [ selfprivacy-overlay.overlay ]; }
# machine specifics
hardware-configuration
# main configuration part
./configuration.nix
# we need NixOS repository git commit sha1 embedded
({ config, ... }: {
system.nixos.label = nixosLabel config;
system.nixos.version = nixosLabel config;
system.configurationRevision = self.rev;
})
];
2023-07-15 12:52:46 +00:00
};
};
};
}