nix-config/flake.nix

174 lines
4.2 KiB
Nix
Raw Normal View History

2025-03-24 12:14:46 +01:00
{
2025-04-04 09:45:57 +02:00
description = "NixOS configuration of DerGrumpf";
2025-03-24 12:14:46 +01:00
# the nixConfig here only affects the flake itself, not the system configuration!
nixConfig = {
extra-substituters = [
"https://nix-community.cachix.org"
2025-09-05 01:03:12 +02:00
"https://hyprland.cachix.org"
2025-03-24 12:14:46 +01:00
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
2025-09-05 01:03:12 +02:00
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
2025-03-24 12:14:46 +01:00
];
};
inputs = {
2025-09-05 01:03:12 +02:00
# Core
2025-04-03 13:06:51 +02:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
2025-09-05 01:03:12 +02:00
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# Desktop ENV
2025-03-25 01:59:21 +01:00
hyprland.url = "github:hyprwm/Hyprland";
2025-09-05 01:03:12 +02:00
hyprland-plugins = {
url = "github:hyprwm/hyprland-plugins";
inputs.hyprland.follows = "hyprland";
};
# Customization
2025-08-16 19:28:53 +02:00
spicetify-nix.url = "github:Gerg-L/spicetify-nix";
2025-09-03 10:03:29 +02:00
nixcord.url = "github:kaylorben/nixcord";
2025-04-08 19:51:19 +02:00
catppuccin.url = "github:catppuccin/nix";
2025-03-25 01:59:21 +01:00
2025-09-05 01:03:12 +02:00
# User Config
2025-04-03 13:06:51 +02:00
home-manager.url = "github:nix-community/home-manager/release-24.11";
2025-03-24 12:14:46 +01:00
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
2025-09-03 10:03:29 +02:00
outputs =
inputs@{
self,
nixpkgs,
home-manager,
catppuccin,
...
}:
2025-04-04 09:45:57 +02:00
2025-09-05 01:03:12 +02:00
let
system = "x86_64-linux";
# Common Configuration
commonModules = [
(
{ config, ... }:
{
nix.settings = {
accept-flake-config = true;
experimental-features = [
"nix-command"
"flakes"
];
2025-09-05 22:30:30 +02:00
auto-optimise-store = true;
};
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 7d";
2025-09-03 10:03:29 +02:00
};
2025-09-05 01:03:12 +02:00
}
)
];
commonHomeManagerConfig =
{
username,
monitorSetup ? "single",
}:
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "backup";
extraSpecialArgs = {
inherit inputs;
inherit username monitorSetup;
};
users.${username} = import ./users/${username}/home.nix;
sharedModules = [
inputs.catppuccin.homeModules.catppuccin
inputs.nixcord.homeModules.nixcord
2025-09-03 10:03:29 +02:00
];
};
2025-09-05 01:03:12 +02:00
};
2025-09-03 10:03:29 +02:00
2025-09-05 01:03:12 +02:00
# System Builder
mkSystem =
{
hostname,
username,
system ? "x86_64-linux",
monitorSetup ? "single",
extraModules ? [ ],
}:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs;
inherit username monitorSetup;
};
modules =
commonModules
++ [
./hosts/${hostname}
2025-09-03 10:03:29 +02:00
./users/${username}/nixos.nix
home-manager.nixosModules.home-manager
2025-09-05 01:03:12 +02:00
(commonHomeManagerConfig { inherit username monitorSetup; })
]
++ extraModules;
2025-09-03 10:03:29 +02:00
2025-09-05 01:03:12 +02:00
};
2025-09-03 10:03:29 +02:00
2025-09-05 01:03:12 +02:00
# ISO configuration
isoConfig = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
(import (nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"))
(
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
neovim
git
wget
curl
];
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
}
)
];
};
2025-09-03 10:03:29 +02:00
2025-09-05 01:03:12 +02:00
in
{
packages.${system}.default = self.nixosConfigurations.iso.config.system.build.isoImage;
nixosConfigurations = {
iso = isoConfig;
qemu = mkSystem {
hostname = "qemu";
username = "phil";
monitorSetup = "single";
};
m920q = mkSystem {
hostname = "m920q";
username = "phil";
monitorSetup = "dual";
};
hp15-n028sg = mkSystem {
hostname = "hp15-n028sg";
username = "phil";
monitorSetup = "dual";
};
2025-09-03 10:03:29 +02:00
};
2025-03-24 12:14:46 +01:00
};
}