2024-03-13 06:55:17 -05:00
|
|
|
{
|
|
|
|
description = "My machines";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
# Nixpkgs and unstable
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
|
|
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
2024-03-18 16:16:39 -05:00
|
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
|
|
|
|
|
|
|
# home-manager
|
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager/release-23.11";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-03-13 06:55:17 -05:00
|
|
|
|
|
|
|
# sops-nix
|
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
# deploy-rs
|
|
|
|
deploy-rs = {
|
|
|
|
url = "github:serokell/deploy-rs";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-03-13 06:55:17 -05:00
|
|
|
# VSCode community extensions
|
|
|
|
nix-vscode-extensions = {
|
|
|
|
url = "github:nix-community/nix-vscode-extensions";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
2024-03-18 04:26:02 -05:00
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, sops-nix
|
|
|
|
, ...
|
|
|
|
} @ inputs:
|
2024-03-24 02:34:14 -05:00
|
|
|
|
2024-03-18 04:26:02 -05:00
|
|
|
let
|
|
|
|
inherit (self) outputs;
|
|
|
|
forAllSystems = nixpkgs.lib.genAttrs [
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-linux"
|
2024-03-24 02:34:14 -05:00
|
|
|
|
2024-03-18 04:26:02 -05:00
|
|
|
];
|
|
|
|
in
|
2024-03-24 02:34:14 -05:00
|
|
|
rec {
|
2024-03-13 06:55:17 -05:00
|
|
|
# Use nixpkgs-fmt for 'nix fmt'
|
2024-03-18 04:06:00 -05:00
|
|
|
formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixpkgs-fmt);
|
2024-03-13 06:55:17 -05:00
|
|
|
|
2024-03-24 02:34:14 -05:00
|
|
|
lib = import ./lib { inherit inputs; } // inputs.nixpkgs.lib;
|
|
|
|
|
2024-03-22 18:57:18 -05:00
|
|
|
|
2024-03-18 16:16:39 -05:00
|
|
|
nixosConfigurations =
|
2024-03-24 02:34:14 -05:00
|
|
|
with self.lib;
|
2024-03-18 16:16:39 -05:00
|
|
|
let
|
|
|
|
defaultModules =
|
2024-03-24 02:34:14 -05:00
|
|
|
(builtins.attrValues lib.nixosModules) ++
|
2024-03-18 16:16:39 -05:00
|
|
|
[
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
];
|
|
|
|
specialArgs = {
|
|
|
|
inherit inputs outputs;
|
|
|
|
};
|
2024-03-23 04:45:09 -05:00
|
|
|
|
|
|
|
# generate a base nixos configuration with the
|
|
|
|
# specified overlays, hardware modules, and any extraModules applied
|
|
|
|
mkNixosConfig =
|
|
|
|
{ hostname
|
|
|
|
, system ? "x86_64-linux"
|
|
|
|
, nixpkgs ? inputs.nixpkgs
|
|
|
|
, hardwareModules
|
|
|
|
, baseModules ? [
|
2024-03-24 02:34:14 -05:00
|
|
|
./nixos/modules/nixos
|
|
|
|
./nixos/profiles
|
2024-03-23 04:45:09 -05:00
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
./nixos/hosts/${hostname}
|
|
|
|
]
|
|
|
|
, extraModules ? [ ]
|
|
|
|
}:
|
|
|
|
nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
modules = baseModules ++ hardwareModules ++ extraModules;
|
|
|
|
specialArgs = { inherit self inputs nixpkgs; };
|
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
in
|
|
|
|
{
|
|
|
|
nixosvm = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit specialArgs;
|
2024-03-13 06:55:17 -05:00
|
|
|
system = "x86_64-linux";
|
2024-03-18 16:16:39 -05:00
|
|
|
modules = defaultModules ++ [
|
|
|
|
./nixos/hosts/nixosvm
|
|
|
|
];
|
|
|
|
};
|
2024-03-19 06:51:31 -05:00
|
|
|
|
2024-03-23 04:45:09 -05:00
|
|
|
# rickenbacker = nixpkgs.lib.nixosSystem {
|
|
|
|
# inherit specialArgs;
|
|
|
|
# system = "x86_64-linux";
|
|
|
|
# modules = defaultModules ++ [
|
|
|
|
# ./nixos/hosts/rickenbacker
|
|
|
|
# ];
|
|
|
|
# };
|
|
|
|
|
|
|
|
"rickenbacker" = mkNixosConfig {
|
|
|
|
hostname = "rickenbacker";
|
2024-03-21 06:59:23 -05:00
|
|
|
system = "x86_64-linux";
|
2024-03-23 04:45:09 -05:00
|
|
|
hardwareModules = [
|
|
|
|
# ./modules/hardware/phil.nix
|
|
|
|
|
|
|
|
];
|
|
|
|
extraModules = [
|
|
|
|
# ./profiles/personal.nix
|
2024-03-21 06:59:23 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-03-23 04:45:09 -05:00
|
|
|
"citadel" = mkNixosConfig {
|
|
|
|
hostname = "citadel";
|
|
|
|
system = "x86_64-linux";
|
|
|
|
hardwareModules = [
|
|
|
|
# ./modules/hardware/phil.nix
|
|
|
|
|
|
|
|
];
|
|
|
|
extraModules = [
|
|
|
|
# ./profiles/personal.nix
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# "kclejeune@aarch64-linux" = mkNixosConfig {
|
|
|
|
# system = "aarch64-linux";
|
|
|
|
# hardwareModules = [./modules/hardware/phil.nix];
|
|
|
|
# extraModules = [./profiles/personal.nix];
|
|
|
|
# };
|
|
|
|
|
|
|
|
|
2024-03-19 06:51:31 -05:00
|
|
|
dns01 = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit specialArgs;
|
|
|
|
system = "aarch64-linux";
|
|
|
|
modules = defaultModules ++ [
|
|
|
|
./nixos/hosts/dns01
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-03-20 17:16:30 -05:00
|
|
|
# dns02 = nixpkgs.lib.nixosSystem {
|
|
|
|
# inherit specialArgs;
|
|
|
|
# system = "aarch64-linux";
|
|
|
|
# modules = defaultModules ++ [
|
|
|
|
# ./nixos/hosts/dns02
|
|
|
|
# ];
|
|
|
|
# };
|
2024-03-19 06:53:14 -05:00
|
|
|
|
2024-03-18 16:16:39 -05:00
|
|
|
# isoimage = nixpkgs.lib.nixosSystem {
|
|
|
|
# system = "x86_64-linux";
|
|
|
|
# inherit specialArgs;
|
|
|
|
# modules = defaultModules ++ [
|
|
|
|
# "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix"
|
|
|
|
# { isoImage.squashfsCompression = "gzip -Xcompression-level 1"; }
|
|
|
|
# ./nixos/iso
|
|
|
|
# ];
|
|
|
|
# };
|
2024-03-13 06:55:17 -05:00
|
|
|
|
2024-03-18 16:16:39 -05:00
|
|
|
# nix build .#images.rpi4
|
|
|
|
rpi4 = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit specialArgs;
|
|
|
|
|
|
|
|
modules = defaultModules ++ [
|
|
|
|
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
|
|
|
|
./nixos/hosts/images/sd-image
|
2024-03-13 06:55:17 -05:00
|
|
|
];
|
|
|
|
};
|
2024-03-21 05:30:11 -05:00
|
|
|
# nix build .#images.iso
|
2024-03-21 04:54:51 -05:00
|
|
|
iso = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit specialArgs;
|
|
|
|
|
|
|
|
modules = defaultModules ++ [
|
|
|
|
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
|
2024-03-21 05:30:11 -05:00
|
|
|
"${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix"
|
|
|
|
./nixos/hosts/images/cd-dvd
|
2024-03-21 04:54:51 -05:00
|
|
|
];
|
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
};
|
2024-03-20 17:16:30 -05:00
|
|
|
# simple shortcut to allow for easier referencing of correct
|
|
|
|
# key for building images
|
|
|
|
# > nix build .#images.rpi4
|
2024-03-18 16:16:39 -05:00
|
|
|
images.rpi4 = nixosConfigurations.rpi4.config.system.build.sdImage;
|
2024-03-21 05:21:08 -05:00
|
|
|
images.iso = nixosConfigurations.iso.config.system.build.isoImage;
|
2024-03-20 17:16:30 -05:00
|
|
|
|
|
|
|
# deploy-rs
|
|
|
|
deploy.nodes =
|
|
|
|
let
|
|
|
|
mkDeployConfig = hostname: configuration: {
|
|
|
|
inherit hostname;
|
|
|
|
profiles.system =
|
|
|
|
let
|
|
|
|
inherit (configuration.config.nixpkgs.hostPlatform) system;
|
|
|
|
in
|
|
|
|
{
|
2024-03-24 02:34:14 -05:00
|
|
|
path = inputs.deploy-rs.lib."${system}".activate.nixos configuration;
|
2024-03-20 17:16:30 -05:00
|
|
|
sshUser = "truxnell";
|
|
|
|
user = "root";
|
|
|
|
sshOpts = [ "-t" ];
|
|
|
|
autoRollback = false;
|
|
|
|
magicRollback = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
dns01 = mkDeployConfig "10.8.10.11" self.nixosConfigurations.dns01;
|
|
|
|
# dns02 = mkDeployConfig "dns02.natallan.com" self.nixosConfigurations.dns02;
|
|
|
|
};
|
|
|
|
|
|
|
|
# deploy-rs: This is highly advised, and will prevent many possible mistakes
|
2024-03-24 02:34:14 -05:00
|
|
|
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
|
2024-03-16 07:46:36 -05:00
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
|
2024-03-16 07:46:36 -05:00
|
|
|
}
|