impermanence-talk/template/flake.nix
2024-04-16 18:35:57 +02:00

71 lines
1.7 KiB
Nix

{
description = "Impermanence Example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence = {
url = "github:nix-community/impermanence";
};
};
outputs = {self, ...} @ inputs: let
system = "x86_64-linux";
pkgs = inputs.nixpkgs.legacyPackages.${system};
in {
nixosConfigurations = {
nixos = inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules = [
inputs.disko.nixosModules.default
inputs.impermanence.nixosModules.impermanence
./system
./custom
];
};
};
formatter = pkgs.alejandra;
apps.${system} = {
install = {
program = "${pkgs.writeShellScript "install" ''
sudo nix run --experimental-features "nix-command flakes" ${inputs.disko} -- --mode disko ${./system/disko.nix}
sudo nixos-generate-config --force --no-filesystems --root /mnt --dir ./system
sudo nixos-install --no-root-password --root /mnt --flake ${self}#nixos
''}";
type = "app";
};
};
devShells.${system} = {
default = pkgs.mkShellNoCC {
packages = [
inputs.disko.packages.${system}.default
];
};
};
templates = {
default = {
path = ./.;
description = "A flake template for a NixOS setup with impermanence.";
welcomeText = ''
To automatically install do a `nix run .#install`
'';
};
};
};
}