Added comments for better readability to flake.nix

This commit is contained in:
Natasha Moongrave 2026-03-24 15:39:47 +01:00
commit 337ce65d74

260
flake.nix
View file

@ -2,139 +2,153 @@
description = "system";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-stable.url = "nixpkgs/nixos-25.11";
nixpkgs-unstable-small.url = "nixpkgs/nixos-unstable-small";
stylix.url = "github:danth/stylix";
typst-within.url = "github:schrottkatze/typst";
crane.url = "github:ipetkov/crane";
nixcord.url = "github:kaylorben/nixcord";
nixpkgs.url = "nixpkgs/nixos-unstable"; # Primary package set: Rolling release unstable
nixpkgs-stable.url = "nixpkgs/nixos-25.11"; # Stable channel used for packages that cannot be volatile
nixpkgs-unstable-small.url = "nixpkgs/nixos-unstable-small"; # Smaller unstable channel with faster binary cache updates
stylix.url = "github:danth/stylix"; # System-wide theming (colors, fonts, wallpaper) via Home Manager
typst-within.url = "github:schrottkatze/typst"; # Custom fork of typst
crane.url = "github:ipetkov/crane"; # Nix rust project library
nixcord.url = "github:kaylorben/nixcord"; # Nix configured Discord
home-manager = {
# home environment nix configuration and config handler
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
# Rust toolchain manager
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
nixpkgs-stable,
nixpkgs-unstable-small,
typst-within,
home-manager,
nixos-hardware,
stylix,
fenix,
crane,
...
}@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pkgs-stable = nixpkgs-stable.legacyPackages.${system};
pkgs-unstable-small = nixpkgs-unstable-small.legacyPackages.${system};
rs-toolchain =
with fenix.packages.${system};
combine [
complete.toolchain
];
crane-lib = (crane.mkLib nixpkgs.legacyPackages.${system}).overrideToolchain rs-toolchain;
rs-programs = final: prev: {
s10e-jrnl = crane-lib.buildPackage {
pname = "s10e-bs";
version = "0.0.1";
src = crane-lib.cleanCargoSource (crane-lib.path ./.);
};
};
in
{
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
devShells."x86_64-linux".default = pkgs.mkShell {
buildInputs = [
rs-toolchain
pkgs.pkg-config
pkgs.glsl_analyzer
pkgs.openssl
];
};
nixosConfigurations = {
monosodium-glutamate-g = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
pkgs-unstable-small
pkgs-stable
rs-programs
;
};
system = "x86_64-linux";
modules = [
stylix.nixosModules.stylix
./hosts/monosodium-glutamate-g/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs-unstable-small pkgs-stable typst-within;
};
home-manager.sharedModules = [
inputs.nixcord.homeModules.nixcord
];
home-manager.users.jade =
{
nixosConfig,
pkgs,
...
}:
{
home.sessionVariables.TZ = nixosConfig.time.timeZone;
home.stateVersion = "${nixosConfig.system.stateVersion}";
};
}
];
};
denkbrett = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
pkgs-unstable-small
pkgs-stable
rs-programs
;
};
system = "x86_64-linux";
modules = [
stylix.nixosModules.stylix
./hosts/denkbrett/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs-unstable-small pkgs-stable typst-within;
};
home-manager.sharedModules = [
inputs.nixcord.homeModules.nixcord
];
home-manager.users.jade =
{
nixosConfig,
pkgs,
...
}:
{
home.sessionVariables.TZ = nixosConfig.time.timeZone;
home.stateVersion = "22.11";
};
}
];
};
outputs = {
self,
nixpkgs,
nixpkgs-stable,
nixpkgs-unstable-small,
typst-within,
home-manager,
nixos-hardware,
stylix,
fenix,
crane,
...
} @ inputs: let
# Global System configuration variables
system = "x86_64-linux";
# Instantiate the three package sets for the target system
pkgs = nixpkgs.legacyPackages.${system};
pkgs-stable = nixpkgs-stable.legacyPackages.${system};
pkgs-unstable-small = nixpkgs-unstable-small.legacyPackages.${system};
# Pre-build the complete rust tool-chain and combine it into a single derivation
rs-toolchain = with fenix.packages.${system};
combine [
complete.toolchain
];
# Set up crane with the custom Rust toolchain above instead of the nixpkgs default
crane-lib = (crane.mkLib nixpkgs.legacyPackages.${system}).overrideToolchain rs-toolchain;
# A nixpkgs overlay that adds locally-built Rust binaries to the package set (NOTE: At least I assume that's what's happening here...)
rs-programs = final: prev: {
s10e-jrnl = crane-lib.buildPackage {
pname = "s10e-bs"; # NOTE: There's a discrepancy between the package names. Idk if it's on purpose or no
version = "0.0.1";
src = crane-lib.cleanCargoSource (crane-lib.path ./.);
};
};
in {
# Default Nix formatter
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
# Global dev shell configuration
devShells."x86_64-linux".default = pkgs.mkShell {
buildInputs = [
rs-toolchain
pkgs.pkg-config
pkgs.glsl_analyzer
pkgs.openssl
];
};
nixosConfigurations = {
# DESKTOP # (NOTE: I assume from our conversations)
monosodium-glutamate-g = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
pkgs-unstable-small
pkgs-stable
rs-programs
;
};
system = "x86_64-linux";
modules = [
stylix.nixosModules.stylix # Enable Stylix themeing
./hosts/monosodium-glutamate-g/configuration.nix # Host specific config
home-manager.nixosModules.home-manager # Embed HM as a host module
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs-unstable-small pkgs-stable typst-within;
};
home-manager.sharedModules = [
inputs.nixcord.homeModules.nixcord # Enable Nixcord as an HM module for all users
];
# HM CONFIG: jade
home-manager.users.jade = {
nixosConfig,
pkgs,
...
}: {
# Mirror the system timezone into the user session
home.sessionVariables.TZ = nixosConfig.time.timeZone;
# Pin HM state version to system state version to keep migration in sync
home.stateVersion = "${nixosConfig.system.stateVersion}";
};
}
];
};
# DEVICE # (NOTE: I got no clue what this is, fix it urself)
denkbrett = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
pkgs-unstable-small
pkgs-stable
rs-programs
;
};
system = "x86_64-linux"; # NOTE: Maybe use ${system} ?
modules = [
# Do the same as in the Desktop (MGS)
stylix.nixosModules.stylix
./hosts/denkbrett/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs-unstable-small pkgs-stable typst-within;
};
home-manager.sharedModules = [
inputs.nixcord.homeModules.nixcord
];
home-manager.users.jade = {
nixosConfig,
pkgs,
...
}: {
home.sessionVariables.TZ = nixosConfig.time.timeZone;
home.stateVersion = "22.11"; # Pin to an older version
};
}
];
};
};
};
}