2024-03-13 06:55:17 -05:00
|
|
|
{
|
2024-03-30 19:37:57 -05:00
|
|
|
description = "My nixos homelab";
|
2024-03-13 06:55:17 -05:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
# Nixpkgs and unstable
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
|
|
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
2024-03-30 19:37:57 -05:00
|
|
|
|
2024-04-29 06:48:13 -05:00
|
|
|
# impermanence
|
|
|
|
# https://github.com/nix-community/impermanence
|
|
|
|
impermanence.url = "github:nix-community/impermanence";
|
|
|
|
|
2024-04-02 20:09:39 -05:00
|
|
|
# nur
|
|
|
|
nur.url = "github:nix-community/NUR";
|
|
|
|
|
2024-03-30 19:37:57 -05:00
|
|
|
# nix-community hardware quirks
|
|
|
|
# https://github.com/nix-community
|
2024-03-18 16:16:39 -05:00
|
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
|
|
|
|
2024-03-30 19:37:57 -05:00
|
|
|
# home-manager - home user+dotfile manager
|
|
|
|
# https://github.com/nix-community/home-manager
|
2024-03-18 16:16:39 -05:00
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager/release-23.11";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-03-13 06:55:17 -05:00
|
|
|
|
2024-03-30 19:37:57 -05:00
|
|
|
# sops-nix - secrets with mozilla sops
|
|
|
|
# https://github.com/Mic92/sops-nix
|
2024-03-13 06:55:17 -05:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-03-30 19:37:57 -05:00
|
|
|
|
2024-03-13 06:55:17 -05:00
|
|
|
# VSCode community extensions
|
2024-03-30 19:37:57 -05:00
|
|
|
# https://github.com/nix-community/nix-vscode-extensions
|
2024-03-13 06:55:17 -05:00
|
|
|
nix-vscode-extensions = {
|
|
|
|
url = "github:nix-community/nix-vscode-extensions";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-06 01:24:47 -05:00
|
|
|
|
|
|
|
# nix-index database
|
|
|
|
# https://github.com/nix-community/nix-index-database
|
|
|
|
nix-index-database = {
|
|
|
|
url = "github:nix-community/nix-index-database";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-05-10 10:06:16 -05:00
|
|
|
# nix-inspect - inspect nix derivations usingn a TUI interface
|
|
|
|
# https://github.com/bluskript/nix-inspect
|
2024-04-14 00:44:46 -05:00
|
|
|
nix-inspect = {
|
|
|
|
url = "github:bluskript/nix-inspect";
|
|
|
|
};
|
2024-03-13 06:55:17 -05:00
|
|
|
};
|
2024-03-18 04:26:02 -05:00
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, sops-nix
|
2024-03-30 19:37:57 -05:00
|
|
|
, home-manager
|
|
|
|
, nix-vscode-extensions
|
2024-04-29 06:48:13 -05:00
|
|
|
, impermanence
|
2024-03-18 04:26:02 -05:00
|
|
|
, ...
|
|
|
|
} @ 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-29 17:26:56 -05:00
|
|
|
|
2024-03-18 04:26:02 -05:00
|
|
|
in
|
2024-04-24 00:50:08 -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-04-10 03:00:25 -05:00
|
|
|
# setup devshells against shell.nix
|
|
|
|
devShells = forAllSystems (pkgs: import ./shell.nix { inherit pkgs; });
|
|
|
|
|
2024-04-24 00:50:08 -05:00
|
|
|
# extend lib with my custom functions
|
|
|
|
lib = nixpkgs.lib.extend (
|
|
|
|
final: prev: {
|
|
|
|
inherit inputs;
|
|
|
|
myLib = import ./nixos/lib { inherit inputs; lib = final; };
|
|
|
|
}
|
|
|
|
);
|
2024-04-10 03:00:25 -05:00
|
|
|
|
2024-03-18 16:16:39 -05:00
|
|
|
nixosConfigurations =
|
2024-04-24 00:50:08 -05:00
|
|
|
with self.lib;
|
2024-03-18 16:16:39 -05:00
|
|
|
let
|
|
|
|
specialArgs = {
|
|
|
|
inherit inputs outputs;
|
|
|
|
};
|
2024-03-30 19:37:57 -05:00
|
|
|
# Import overlays for building nixosconfig with them.
|
2024-03-29 17:26:56 -05:00
|
|
|
overlays = import ./nixos/overlays { inherit inputs; };
|
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
|
2024-03-24 07:21:13 -05:00
|
|
|
, hardwareModules ? [ ]
|
2024-03-30 19:37:57 -05:00
|
|
|
# basemodules is the base of the entire machine building
|
|
|
|
# here we import all the modules and setup home-manager
|
2024-03-23 04:45:09 -05:00
|
|
|
, baseModules ? [
|
|
|
|
sops-nix.nixosModules.sops
|
2024-03-30 19:37:57 -05:00
|
|
|
home-manager.nixosModules.home-manager
|
2024-04-29 06:48:13 -05:00
|
|
|
impermanence.nixosModules.impermanence
|
2024-03-30 19:37:57 -05:00
|
|
|
./nixos/profiles/global.nix # all machines get a global profile
|
|
|
|
./nixos/modules/nixos # all machines get nixos modules
|
|
|
|
./nixos/hosts/${hostname} # load this host's config folder for machine-specific config
|
|
|
|
{
|
|
|
|
home-manager = {
|
|
|
|
useUserPackages = true;
|
|
|
|
useGlobalPkgs = true;
|
|
|
|
extraSpecialArgs = {
|
|
|
|
inherit inputs hostname system;
|
|
|
|
};
|
2024-04-06 01:24:47 -05:00
|
|
|
|
2024-03-30 19:37:57 -05:00
|
|
|
};
|
|
|
|
}
|
2024-03-23 04:45:09 -05:00
|
|
|
]
|
2024-03-24 17:23:35 -05:00
|
|
|
, profileModules ? [ ]
|
2024-03-23 04:45:09 -05:00
|
|
|
}:
|
|
|
|
nixpkgs.lib.nixosSystem {
|
2024-04-24 00:50:08 -05:00
|
|
|
inherit system lib;
|
2024-03-24 17:23:35 -05:00
|
|
|
modules = baseModules ++ hardwareModules ++ profileModules;
|
2024-03-23 04:45:09 -05:00
|
|
|
specialArgs = { inherit self inputs nixpkgs; };
|
2024-03-29 17:26:56 -05:00
|
|
|
# Add our overlays
|
|
|
|
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = builtins.attrValues overlays;
|
|
|
|
config = {
|
|
|
|
allowUnfree = true;
|
|
|
|
allowUnfreePredicate = _: true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-23 04:45:09 -05:00
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
in
|
2024-03-30 19:37:57 -05:00
|
|
|
rec {
|
2024-05-10 10:06:16 -05:00
|
|
|
"durincore" = mkNixosConfig {
|
|
|
|
# NixOS laptop - T470 Thinkpad
|
|
|
|
hostname = "durincore";
|
2024-03-21 06:59:23 -05:00
|
|
|
system = "x86_64-linux";
|
2024-03-23 04:45:09 -05:00
|
|
|
hardwareModules = [
|
2024-05-10 10:12:30 -05:00
|
|
|
./nixos/profiles/hw-thinkpad-t470.nix
|
2024-05-10 10:06:16 -05:00
|
|
|
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t470s
|
2024-03-21 06:59:23 -05:00
|
|
|
];
|
2024-03-24 17:23:35 -05:00
|
|
|
profileModules = [
|
2024-05-10 10:15:37 -05:00
|
|
|
./nixos/profiles/role-workstation.nix
|
2024-05-05 06:51:48 -05:00
|
|
|
./nixos/profiles/role-dev.nix
|
2024-05-10 10:06:16 -05:00
|
|
|
{ home-manager.users.jahanson = ./nixos/home/jahanson/workstation.nix; }
|
2024-04-02 20:09:39 -05:00
|
|
|
];
|
|
|
|
};
|
2024-05-10 16:50:09 -05:00
|
|
|
"varda" = mkNixosConfig {
|
|
|
|
# Arm64 cax21 @ Hetzner
|
|
|
|
|
|
|
|
hostname = "varda";
|
|
|
|
system = "aarch64-linux";
|
|
|
|
hardwareModules = [
|
|
|
|
./nixos/profiles/hw-hetzner-cax.nix
|
|
|
|
];
|
|
|
|
profileModules = [
|
|
|
|
./nixos/profiles/role-server.nix
|
|
|
|
{ home-manager.users.truxnell = ./nixos/home/jahanson/server.nix; }
|
|
|
|
|
|
|
|
];
|
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
};
|
2024-03-30 19:37:57 -05:00
|
|
|
|
2024-03-30 01:58:53 -05:00
|
|
|
# Convenience output that aggregates the outputs for home, nixos.
|
2024-03-26 07:11:49 -05:00
|
|
|
# Also used in ci to build targets generally.
|
|
|
|
top =
|
|
|
|
let
|
|
|
|
nixtop = nixpkgs.lib.genAttrs
|
|
|
|
(builtins.attrNames inputs.self.nixosConfigurations)
|
|
|
|
(attr: inputs.self.nixosConfigurations.${attr}.config.system.build.toplevel);
|
|
|
|
in
|
2024-04-02 20:09:39 -05:00
|
|
|
nixtop;
|
2024-03-16 07:46:36 -05:00
|
|
|
};
|
2024-03-18 16:16:39 -05:00
|
|
|
|
2024-03-16 07:46:36 -05:00
|
|
|
}
|