templates/system/flake.nix

98 lines
3.1 KiB
Nix

{
description = "A system flake with various options for bootstrapping a complete NixOS install.";
inputs = {
# Import the desired Nix channel. Defaults to unstable, which uses a fully tested rolling release model.
# You can find a list of channels at https://nixos.wiki/wiki/Nix_channels
# To follow a different channel, replace `nixos-unstable` with the channel name, e.g. `nixos-24.05`.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Use Lix in place of Nix.
# If you'd rather use regular Nix, remove `lix-module.nixosModules.default` from the `modules` section below.
# To learn more about Lix, see https://lix.systems/
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.90.0-rc1.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
# Flatpak support
nix-flatpak.url = "github:gmodena/nix-flatpak/v0.4.1";
# SecureBoot support
lanzaboote.url = "github:nix-community/lanzaboote/v0.4.0";
# NixOS hardware quirks
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
# Home-manager support
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
home-manager,
lanzaboote,
lix-module,
nix-flatpak,
nixos-hardware,
nixpkgs,
...
}:
let
###*** IMPORTANT: Please set your system's hostname here ***###
hostName = builtins.abort "Please set the 'hostName' variable in flake.nix";
/*
What kind of system are you running NixOS on?
If you're not sure, leave this as the default.
Options are:
x86_64-linux - (Default) 64-bit PCs.
aarch64-linux - 64-bit ARM PCs.
x86_64-darwin - Intel Macs.
aarch64-darwin - M-series Macs.
*/
platform = "x86_64-linux";
in
{
nixosConfigurations."${hostName}" = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
};
modules = [
{
networking.hostName = hostName;
nixpkgs.hostPlatform = platform;
home-manager = {
/*
When running, Home Manager will use the global package cache.
It will also back up any files that it would otherwise overwrite.
The originals will have the extension ".home-manager_backup".
*/
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "home-manager_backup";
};
}
./modules/autoimport.nix
home-manager.nixosModules.home-manager
lanzaboote.nixosModules.lanzaboote
lix-module.nixosModules.default
nix-flatpak.nixosModules.nix-flatpak
./host/configuration.nix
# NixOS-Hardware
# Add your model from this list: https://github.com/NixOS/nixos-hardware/blob/master/flake.nix
# nixos-hardware.nixosModules.framework-13th-gen-intel
];
};
formatter.${platform} = nixpkgs.legacyPackages.${platform}.nixfmt-rfc-style;
};
}