Files
nixos/Droidnix/flake.nix
T
2026-03-12 19:46:20 +01:00

287 lines
7.7 KiB
Nix

This is my flake.nix.
I want you to create a minimal version of it.
Anything machine-related needs to find a place in machine.nix
Anything user related should be placed in user.nix
user.nix should import the attributes of the user from henrov.nix
I give you my current files:
- first: current flake.nix
- second: machine.nix
- third: the attributes for henrov.nix
Give me three files:
- a flake.nix that has been stripped down as much as possible, keeping the inputs, the cattpucinne theme and the ./generated/top.nix
- a machine.nix in which you moved anything machine-related into machine.nix
- a user.nix in which you moved anything user-related into user.nix
{
description = "Droidnix: A dendritic NixOS + Home Manager configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
catppuccin = {
url = "github:catppuccin/nix";
inputs.nixpkgs.follows = "nixpkgs";
};
zen-browser = {
url = "github:youwen5/zen-browser-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
};
outputs =
inputs@{
self,
nixpkgs,
home-manager,
emacs-overlay,
catppuccin,
zen-browser,
hyprland,
...
}:
let
lib = nixpkgs.lib;
system = "x86_64-linux";
user = import ./assets/flake/users/henrov.nix;
machines = [
"traveldroid"
"maindroid"
];
in
{
nixosConfigurations = lib.genAttrs machines (
machine:
lib.nixosSystem {
inherit system;
modules = [
# Import machine-specific configurations
./assets/flake/machines/${machine}/top.nix
# Home Manager module
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit user inputs;
flakeRoot = ./.;
};
}
# Catppuccin theme module
inputs.catppuccin.nixosModules.catppuccin
# Anchoring all the other nixes
./generated/top.nix
# Enable Home Manager for the user
(
{ config, pkgs, ... }:
{
home-manager.users.${user.username} = {
enable = true;
homeDirectory = "/home/${user.username}";
};
}
)
];
specialArgs = {
inherit user inputs;
flakeRoot = ./.;
};
}
);
# Home Manager configurations for each user/machine
homeConfigurations = lib.genAttrs (map (machine: user.username + "@" + machine) machines) (
userMachine:
let
parts = lib.splitString "@" userMachine;
username = builtins.elemAt parts 0;
machine = builtins.elemAt parts 1;
in
home-manager.lib.homeManagerConfiguration {
inherit system;
configuration = import ./assets/flake/users/${username}/home.nix {
inherit inputs user;
pkgs = import nixpkgs { inherit system; };
};
extraSpecialArgs = {
inherit user inputs;
flakeRoot = ./.;
};
}
);
devShells.${system}.default = import ./assets/flake/terminal_shell/devshell.nix {
inherit (nixpkgs.legacyPackages.${system}) mkShell;
};
};
}
{ config, pkgs, lib, user, inputs, flakeRoot,... }:
{
imports = [
./boot.nix
./hardware-configuration.nix
];
options = {
wm = lib.mkOption {
type = lib.types.str;
default = "hyprland";
description = "Type of window manager to use";
};
};
config = {
# Minimal settings that must be defined here
networking.hostName = "traveldroid";
wm.type = "hyprland";
# User configuration
users.users.${user.username} = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
hashedPassword = user.hashedPassword;
home = user.homeDirectory;
};
# Optional: Enable auto-login for testing
services.getty.autologinUser = user.username;
};
}
{
username = "henrov";
hashedPassword = "$6$ISAmsPLyFi7idYXr$VmZsq.zMsyh1irSkyDNqtorNXG0oEHbbMVqTii1t8bymvrQ5ZQmbdi4OiBNeNYe/huHGrojXM.3TST2fTLz0T.";
homeDirectory = "/home/henrov";
stateVersion = "25.11";
locale = "nl_NL.UTF-8";
}
{
description = "Droidnix: A dendritic NixOS + Home Manager configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
catppuccin = {
url = "github:catppuccin/nix";
inputs.nixpkgs.follows = "nixpkgs";
};
zen-browser = {
url = "github:youwen5/zen-browser-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
};
outputs =
inputs@{
self,
nixpkgs,
home-manager,
emacs-overlay,
catppuccin,
zen-browser,
hyprland,
...
}:
let
lib = nixpkgs.lib;
system = "x86_64-linux";
user = import ./assets/flake/users/henrov.nix;
machines = [
"traveldroid"
"maindroid"
];
in
{
nixosConfigurations = lib.genAttrs machines (
machine:
lib.nixosSystem {
inherit system;
modules = [
# Import machine-specific configurations
./assets/flake/machines/${machine}/top.nix
# Home Manager module
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit user inputs;
flakeRoot = ./.;
};
}
# Catppuccin theme module
inputs.catppuccin.nixosModules.catppuccin
# Anchoring all the other nixes
./generated/top.nix
# Enable Home Manager for the user
(
{ config, pkgs, ... }:
{
home-manager.users.${user.username} = {
enable = true;
homeDirectory = "/home/${user.username}";
};
}
)
];
specialArgs = {
inherit user inputs;
flakeRoot = ./.;
};
}
);
# Home Manager configurations for each user/machine
homeConfigurations = lib.genAttrs (map (machine: user.username + "@" + machine) machines) (
userMachine:
let
parts = lib.splitString "@" userMachine;
username = builtins.elemAt parts 0;
machine = builtins.elemAt parts 1;
in
home-manager.lib.homeManagerConfiguration {
inherit system;
configuration = import ./assets/flake/users/${username}/home.nix {
inherit inputs user;
pkgs = import nixpkgs { inherit system; };
};
extraSpecialArgs = {
inherit user inputs;
flakeRoot = ./.;
};
}
);
devShells.${system}.default = import ./assets/flake/terminal_shell/devshell.nix {
inherit (nixpkgs.legacyPackages.${system}) mkShell;
};
};
}