mirror of
https://github.com/Jokiller230/puzzlevision.git
synced 2025-05-13 06:59:48 +02:00
🚧 Initial work on generating homeConfigurations output + syntax changes
This commit is contained in:
parent
f139b88c0b
commit
f89cbcc552
12 changed files with 131 additions and 106 deletions
28
flake.lock
generated
28
flake.lock
generated
|
@ -2,15 +2,15 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"easy-hosts": {
|
"easy-hosts": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736680851,
|
"lastModified": 1739315072,
|
||||||
"narHash": "sha256-KUkO4H0W+1u5piwAzIzCuVhamQ0L3io8vR61NrODtHs=",
|
"narHash": "sha256-m0Lzdrj95GbdmKhqlTKkr4vvHy2Ghdi1GxISOKqUeSA=",
|
||||||
"owner": "isabelroses",
|
"owner": "tgirlcloud",
|
||||||
"repo": "easy-hosts",
|
"repo": "easy-hosts",
|
||||||
"rev": "450d2ae463bb8fb55194f33073ebdd83b8b7ddaa",
|
"rev": "e96af44cae1f48a1a94f2471faee92caf22aa45f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "isabelroses",
|
"owner": "tgirlcloud",
|
||||||
"repo": "easy-hosts",
|
"repo": "easy-hosts",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736143030,
|
"lastModified": 1741352980,
|
||||||
"narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=",
|
"narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de",
|
"rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -42,11 +42,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736785676,
|
"lastModified": 1742305478,
|
||||||
"narHash": "sha256-TY0jUwR3EW0fnS0X5wXMAVy6h4Z7Y6a3m+Yq++C9AyE=",
|
"narHash": "sha256-iYCinzZnnUeCkZ031qGRwPdwRsqW6o9Y0MgGpA7Zva4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "fc52a210b60f2f52c74eac41a8647c1573d2071d",
|
"rev": "fb74bb76d94a6c55632376c931fc108131260ee9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -57,11 +57,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736701207,
|
"lastModified": 1742069588,
|
||||||
"narHash": "sha256-jG/+MvjVY7SlTakzZ2fJ5dC3V1PrKKrUEOEE30jrOKA=",
|
"narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ed4a395ea001367c1f13d34b1e01aa10290f67d6",
|
"rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
22
flake.nix
22
flake.nix
|
@ -1,9 +1,23 @@
|
||||||
{
|
{
|
||||||
description = "Jo's dotfiles";
|
description = "Jo's dotfiles";
|
||||||
|
|
||||||
|
nixConfig = {
|
||||||
|
experimental-features = [
|
||||||
|
"flakes"
|
||||||
|
"nix-command"
|
||||||
|
];
|
||||||
|
extra-substituters = [
|
||||||
|
"https://nix-community.cachix.org"
|
||||||
|
];
|
||||||
|
extra-trusted-public-keys = [
|
||||||
|
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||||
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
easy-hosts.url = "github:isabelroses/easy-hosts";
|
easy-hosts.url = "github:tgirlcloud/easy-hosts";
|
||||||
|
|
||||||
flake-parts = {
|
flake-parts = {
|
||||||
url = "github:hercules-ci/flake-parts";
|
url = "github:hercules-ci/flake-parts";
|
||||||
|
@ -16,15 +30,15 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { flake-parts, ... }@inputs:
|
outputs = {flake-parts, ...} @ inputs:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
debug = true;
|
debug = true;
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
./modules/flake
|
./modules/flake
|
||||||
];
|
];
|
||||||
|
|
||||||
systems = [ "x86_64-linux" ];
|
systems = ["x86_64-linux"];
|
||||||
flake = {
|
flake = {
|
||||||
# Exposing the flake namespace
|
# Exposing the flake namespace
|
||||||
namespace = "puzzlevision";
|
namespace = "puzzlevision";
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
{
|
{lib, ...}: {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
# Create a NixOS module option on a single line.
|
# Create a NixOS module option on a single line.
|
||||||
mkOpt =
|
mkOpt = type: default: description:
|
||||||
type: default: description:
|
lib.mkOption {inherit type default description;};
|
||||||
lib.mkOption { inherit type default description; };
|
|
||||||
|
|
||||||
mkBool =
|
mkBool = default: description:
|
||||||
default: description:
|
lib.mkOption {
|
||||||
lib.mkOption { inherit default description; type = lib.types.bool; };
|
inherit default description;
|
||||||
|
type = lib.types.bool;
|
||||||
|
};
|
||||||
|
|
||||||
# Todo: add mkIfElse function
|
# Todo: add mkIfElse function
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
{
|
{config, ...}: {
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
# Apply some useful module arguments.
|
# Apply some useful module arguments.
|
||||||
_module.args = {
|
_module.args = {
|
||||||
namespace = config.flake.namespace;
|
namespace = config.flake.namespace;
|
||||||
|
|
|
@ -11,5 +11,8 @@
|
||||||
|
|
||||||
# Automagically imports systems from "/systems/arch-classname/system-name".
|
# Automagically imports systems from "/systems/arch-classname/system-name".
|
||||||
./systems.nix
|
./systems.nix
|
||||||
|
|
||||||
|
# Automagically imports homes from "/homes/user-name".
|
||||||
|
./homes.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
22
modules/flake/homes.nix
Normal file
22
modules/flake/homes.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
puzzlelib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
HomeConfiguration = args: let
|
||||||
|
nixpkgs = inputs.nixpkgs;
|
||||||
|
in
|
||||||
|
inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
|
modules = (puzzlelib.dirToModuleList ../home) ++ args.modules;
|
||||||
|
extraSpecialArgs =
|
||||||
|
{
|
||||||
|
inherit (args) nixpkgs;
|
||||||
|
}
|
||||||
|
// args.extraSpecialArgs;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
perSystem = {
|
||||||
|
# TODO Dynamically export homeConfigurations by consuming contents of /homes/user-name
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,53 +2,49 @@
|
||||||
lib,
|
lib,
|
||||||
puzzlelib,
|
puzzlelib,
|
||||||
...
|
...
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
# Utility function to read a directory and return its contents.
|
# Utility function to read a directory and return its contents.
|
||||||
readDirectory = directory: builtins.readDir directory;
|
readDirectory = directory: builtins.readDir directory;
|
||||||
|
|
||||||
# Utility function to handle each filesystem entity (file or directory).
|
# Utility function to handle each filesystem entity (file or directory).
|
||||||
filesystemEntityToAttrSet = directory: importArgs: name: type:
|
filesystemEntityToAttrSet = directory: importArgs: name: type:
|
||||||
if type == "directory" then
|
if type == "directory"
|
||||||
dirToAttrSet "${directory}/${name}" importArgs
|
then dirToAttrSet "${directory}/${name}" importArgs
|
||||||
else if name == "default.nix" then
|
else if name == "default.nix"
|
||||||
import "${directory}/${name}" importArgs
|
then import "${directory}/${name}" importArgs
|
||||||
else
|
else {};
|
||||||
{};
|
|
||||||
|
|
||||||
filesystemEntityToList = directory: name: type:
|
filesystemEntityToList = directory: name: type:
|
||||||
if type == "directory" then
|
if type == "directory"
|
||||||
dirToModuleList "${directory}/${name}"
|
then dirToModuleList "${directory}/${name}"
|
||||||
else if name == "default.nix" then
|
else if name == "default.nix"
|
||||||
[ "${directory}/${name}" ]
|
then ["${directory}/${name}"]
|
||||||
else
|
else [];
|
||||||
[];
|
|
||||||
|
|
||||||
dirToModuleList = directory:
|
dirToModuleList = directory: let
|
||||||
let
|
readDir = readDirectory directory;
|
||||||
readDir = readDirectory directory;
|
in
|
||||||
in
|
builtins.foldl' (
|
||||||
builtins.foldl' (acc: name:
|
acc: name:
|
||||||
acc ++ (filesystemEntityToList directory name (builtins.getAttr name readDir))
|
acc ++ (filesystemEntityToList directory name (builtins.getAttr name readDir))
|
||||||
) [] (builtins.attrNames readDir);
|
) [] (builtins.attrNames readDir);
|
||||||
|
|
||||||
# Utility function to recursively load modules from a directory.
|
# Utility function to recursively load modules from a directory.
|
||||||
dirToAttrSet = directory: importArgs:
|
dirToAttrSet = directory: importArgs: let
|
||||||
let
|
# Read provided directory only once at the very start and save the result.
|
||||||
# Read provided directory only once at the very start and save the result.
|
readDir = readDirectory directory;
|
||||||
readDir = readDirectory directory;
|
in
|
||||||
in
|
# Iterate over the attr names of a readDir operation.
|
||||||
# Iterate over the attr names of a readDir operation.
|
builtins.foldl' (
|
||||||
builtins.foldl' (acc: name:
|
acc: name:
|
||||||
# Merge outputs of handling a filesystem entity (file or directory) into accumulator.
|
# Merge outputs of handling a filesystem entity (file or directory) into accumulator.
|
||||||
# Files return attribute sets with their resulting expressions, directories return the result of multiple file handling operations.
|
# Files return attribute sets with their resulting expressions, directories return the result of multiple file handling operations.
|
||||||
acc // (filesystemEntityToAttrSet directory importArgs name (builtins.getAttr name readDir))
|
acc // (filesystemEntityToAttrSet directory importArgs name (builtins.getAttr name readDir))
|
||||||
) {} (builtins.attrNames readDir);
|
) {} (builtins.attrNames readDir);
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
# Add lib.${namespace} attribute to module arguments, for easy access.
|
# Add lib.${namespace} attribute to module arguments, for easy access.
|
||||||
# Additionally, pass on dirToAttrSet method on lib.${namespace} for reusability in other modules.
|
# Additionally, pass on dirToAttrSet method on lib.${namespace} for reusability in other modules.
|
||||||
_module.args = {
|
_module.args = {
|
||||||
puzzlelib = dirToAttrSet ../../lib { inherit lib puzzlelib; } // { inherit dirToAttrSet dirToModuleList filesystemEntityToList filesystemEntityToAttrSet; };
|
puzzlelib = dirToAttrSet ../../lib {inherit lib puzzlelib;} // {inherit dirToAttrSet dirToModuleList filesystemEntityToList filesystemEntityToAttrSet;};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
namespace,
|
namespace,
|
||||||
puzzlelib,
|
puzzlelib,
|
||||||
...
|
...
|
||||||
}:
|
}: {
|
||||||
{
|
imports = [inputs.easy-hosts.flakeModule];
|
||||||
imports = [ inputs.easy-hosts.flakeModule ];
|
|
||||||
|
|
||||||
easyHosts = {
|
easyHosts = {
|
||||||
autoConstruct = true;
|
autoConstruct = true;
|
||||||
|
@ -19,11 +18,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
perClass = class: {
|
perClass = class: {
|
||||||
modules = [
|
modules =
|
||||||
(lib.optionals (class == "nixos") [
|
(lib.optionals (class == "nixos") [
|
||||||
inputs.home-manager.nixosModules.default
|
inputs.home-manager.nixosModules.default
|
||||||
])
|
])
|
||||||
] ++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname.
|
++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname.
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
2
modules/home/desktop/gnome.nix
Normal file
2
modules/home/desktop/gnome.nix
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{}: {
|
||||||
|
}
|
|
@ -3,13 +3,11 @@
|
||||||
config,
|
config,
|
||||||
namespace,
|
namespace,
|
||||||
...
|
...
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
inherit (lib) mkEnableOption mkIf;
|
inherit (lib) mkEnableOption mkIf;
|
||||||
cfg = config.${namespace}.desktop.gnome;
|
cfg = config.${namespace}.desktop.gnome;
|
||||||
in
|
in {
|
||||||
{
|
options.${namespace}.desktop.gnome = {enable = mkEnableOption "Enable the gnome desktop environment ${namespace}";};
|
||||||
options.${namespace}.desktop.gnome = { enable = mkEnableOption "Enable the gnome desktop environment ${namespace}"; };
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.xserver.enable = true;
|
services.xserver.enable = true;
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
namespace,
|
namespace,
|
||||||
puzzlelib,
|
puzzlelib,
|
||||||
...
|
...
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
inherit (lib) mkIf mkMerge;
|
inherit (lib) mkIf mkMerge;
|
||||||
inherit (puzzlelib) mkOpt mkBool;
|
inherit (puzzlelib) mkOpt mkBool;
|
||||||
|
|
||||||
cfg = config.${namespace}.utils.vm;
|
cfg = config.${namespace}.utils.vm;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.${namespace}.utils.vm = {
|
options.${namespace}.utils.vm = {
|
||||||
enable = mkBool true "Whether to enable custom vm presets";
|
enable = mkBool true "Whether to enable custom vm presets";
|
||||||
preset = mkOpt lib.types.str "performance" "Specify the prefered vm settings preset: performance, balance or powersave";
|
preset = mkOpt lib.types.str "performance" "Specify the prefered vm settings preset: performance, balance or powersave";
|
||||||
|
@ -19,25 +17,28 @@ in
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
virtualisation.vmVariant = mkMerge [
|
virtualisation.vmVariant = mkMerge [
|
||||||
(mkIf cfg.preset == "performance" {
|
(mkIf cfg.preset
|
||||||
virtualisation = {
|
== "performance" {
|
||||||
cores = 6;
|
virtualisation = {
|
||||||
memorySize = 4096;
|
cores = 6;
|
||||||
graphics = true;
|
memorySize = 4096;
|
||||||
};
|
graphics = true;
|
||||||
})
|
};
|
||||||
(mkIf cfg.preset == "balance" {
|
})
|
||||||
virtualisation = {
|
(mkIf cfg.preset
|
||||||
cores = 4;
|
== "balance" {
|
||||||
memorySize = 2048;
|
virtualisation = {
|
||||||
};
|
cores = 4;
|
||||||
})
|
memorySize = 2048;
|
||||||
(mkIf cfg.preset == "powersave" {
|
};
|
||||||
virtualisation = {
|
})
|
||||||
cores = 2;
|
(mkIf cfg.preset
|
||||||
memorySize = 1024;
|
== "powersave" {
|
||||||
};
|
virtualisation = {
|
||||||
})
|
cores = 2;
|
||||||
|
memorySize = 1024;
|
||||||
|
};
|
||||||
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
{
|
{pkgs, ...}: {
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
imports = [
|
imports = [
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
];
|
];
|
||||||
|
@ -14,7 +10,6 @@
|
||||||
# System configuration
|
# System configuration
|
||||||
puzzlevision = {
|
puzzlevision = {
|
||||||
# Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations
|
# Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations
|
||||||
# mainUser = "jo";
|
|
||||||
# users = [ "jo" ];
|
# users = [ "jo" ];
|
||||||
|
|
||||||
desktop.gnome.enable = true;
|
desktop.gnome.enable = true;
|
||||||
|
@ -22,6 +17,8 @@
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
ghostty
|
ghostty
|
||||||
|
firefox
|
||||||
|
vscodium
|
||||||
];
|
];
|
||||||
|
|
||||||
system.stateVersion = "25.05";
|
system.stateVersion = "25.05";
|
||||||
|
|
Loading…
Add table
Reference in a new issue