diff --git a/flake.lock b/flake.lock index 526374f..7ba0bdb 100755 --- a/flake.lock +++ b/flake.lock @@ -9,17 +9,39 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1737459777, - "narHash": "sha256-IlydxBpzH13HyDXq8YM3y9gz/SkN0pDpWeMXNt/+EyE=", + "lastModified": 1749757487, + "narHash": "sha256-yPxNQ2wo4Iiv/QiacFcL4gPC/uansnY6FmPvW53fUhg=", "owner": "chaotic-cx", "repo": "nyx", - "rev": "18c577a2a160453f4a6b4050fb0eac7d28b92ead", + "rev": "12314126ea2c78758055c1f413182fbea617801c", "type": "github" }, "original": { "owner": "chaotic-cx", + "ref": "nyxpkgs-unstable", "repo": "nyx", - "rev": "18c577a2a160453f4a6b4050fb0eac7d28b92ead", + "type": "github" + } + }, + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1749105467, + "narHash": "sha256-hXh76y/wDl15almBcqvjryB50B0BaiXJKk20f314RoE=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "6bc76b872374845ba9d645a2f012b764fecd765f", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", "type": "github" } }, @@ -45,6 +67,22 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -337,6 +375,7 @@ "root": { "inputs": { "chaotic": "chaotic", + "deploy-rs": "deploy-rs", "hydenix": "hydenix", "nix-gaming": "nix-gaming", "nix-index-database": "nix-index-database", @@ -360,6 +399,39 @@ "repo": "rust-analyzer", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index ef6fc0d..9a4820c 100755 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "template for hydenix"; inputs = { - chaotic.url = "github:chaotic-cx/nyx/18c577a2a160453f4a6b4050fb0eac7d28b92ead"; + chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable"; # User's nixpkgs - for user packages nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; @@ -24,6 +24,11 @@ url = "github:nix-community/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; }; + + deploy-rs = { + url = "github:serokell/deploy-rs"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -61,20 +66,76 @@ hydenix-inputs = inputs.hydenix.inputs // inputs.hydenix.lib // inputs.hydenix; flake = inputs.self.outPath; }; + + # All below is for deploy-rs + system = inputs.hydenix.lib.system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ inputs.deploy-rs.overlays.default ]; + }; + + mkDeployNode = hostname: { + hostname = hostname; + profiles.system = { + # Change from root to your user + user = "${vars.user}"; + path = inputs.deploy-rs.lib.${system}.activate.nixos inputs.self.nixosConfigurations.${hostname}; + sshUser = "${vars.user}"; + interactiveSudo = true; + sshOpts = [ + "-p" + "22" + ]; + magicRollback = true; + confirmTimeout = 300; + }; + }; in { nixosConfigurations = { fern = mkHost "fern"; oak = mkHost "oak"; - # TODO: temp host for rebuild iso - nixos = mkHost "oak"; + "fern.local" = mkHost "fern"; + "oak.local" = mkHost "oak"; + }; + + deploy.nodes = { + fern = mkDeployNode "fern.local"; + oak = mkDeployNode "oak.local"; }; packages.${inputs.hydenix.lib.system} = { fern-vm = mkVm "fern"; oak-vm = mkVm "oak"; + build-iso = isoConfig.build-iso; burn-iso = isoConfig.burn-iso; + + rb = pkgs.writeShellScriptBin "rb" '' + set -euo pipefail + host=$1 + case "$host" in + "oak") + ${pkgs.deploy-rs}/bin/deploy --skip-checks .#oak ;; + "fern") + ${pkgs.deploy-rs}/bin/deploy --skip-checks .#fern ;; + "all") + ${pkgs.deploy-rs}/bin/deploy --skip-checks .#oak + ${pkgs.deploy-rs}/bin/deploy --skip-checks .#fern + ;; + *) echo "Usage: rb [oak|fern|all]" >&2; exit 1 ;; + esac + ''; + }; + + # Only check the specific deployment node + checks.${system} = { + oak-check = inputs.deploy-rs.lib.${system}.deployChecks { + nodes.oak = inputs.self.deploy.nodes.oak; + }; + fern-check = inputs.deploy-rs.lib.${system}.deployChecks { + nodes.fern = inputs.self.deploy.nodes.fern; + }; }; }; } diff --git a/hosts/fern/default.nix b/hosts/fern/default.nix index 3589f60..72b2d61 100644 --- a/hosts/fern/default.nix +++ b/hosts/fern/default.nix @@ -42,7 +42,7 @@ in { # hm import imports = [ - ../../modules/hm/desktops + ../../modules/hm/desktops/hydenix.nix ]; desktops.hydenix = { @@ -69,4 +69,6 @@ in ]; shell = pkgs.zsh; }; + + system.stateVersion = "25.05"; } diff --git a/hosts/oak/default.nix b/hosts/oak/default.nix index a8f6700..8e019dc 100644 --- a/hosts/oak/default.nix +++ b/hosts/oak/default.nix @@ -59,7 +59,7 @@ in { # hm import imports = [ - ../../modules/hm/desktops + ../../modules/hm/desktops/hydenix.nix ../../modules/hm/hosts/oak ]; @@ -89,11 +89,4 @@ in ]; shell = pkgs.zsh; }; - - services = { - printing = { # CUPS - enable = true; - drivers = [ pkgs.cnijfilter2 ]; - }; - }; } diff --git a/modules/hm/common/browser/default.nix b/modules/hm/common/browser/default.nix new file mode 100644 index 0000000..f83c5ac --- /dev/null +++ b/modules/hm/common/browser/default.nix @@ -0,0 +1,38 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.modules.common.browser; +in +{ + options.modules.common.browser = { + emulators = lib.mkOption { + type = lib.types.listOf (lib.types.enum ["chromium" "chrome" "firefox" "brave" "vivaldi" "edge"]); + default = []; + }; + + driver.enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable browser drivers for automation (e.g., Selenium, Puppeteer)"; + }; + }; + + config = { + home.packages = with pkgs; + lib.unique ( + (lib.optionals (lib.elem "chromium" cfg.emulators) [chromium]) ++ + (lib.optionals (lib.elem "chrome" cfg.emulators) [google-chrome]) ++ + (lib.optionals (lib.elem "firefox" cfg.emulators) [firefox]) ++ + (lib.optionals (lib.elem "brave" cfg.emulators) [brave]) ++ + (lib.optionals (lib.elem "vivaldi" cfg.emulators) [vivaldi]) ++ + (lib.optionals (lib.elem "edge" cfg.emulators) [microsoft-edge]) ++ + (lib.optionals + (cfg.driver.enable && + (lib.any (browser: lib.elem browser cfg.emulators) + [ "chromium" "chrome" "vivaldi" "brave" ])) + [chromedriver]) ++ + (lib.optionals (cfg.driver.enable && lib.elem "firefox" cfg.emulators) [geckodriver]) ++ + (lib.optionals (cfg.driver.enable && lib.elem "edge" cfg.emulators) [msedgedriver]) + ); + }; +} \ No newline at end of file diff --git a/modules/hm/common/communication/mail/default.nix b/modules/hm/common/communication/mail/default.nix index d0ab8ab..f0f18b4 100644 --- a/modules/hm/common/communication/mail/default.nix +++ b/modules/hm/common/communication/mail/default.nix @@ -17,16 +17,14 @@ let in { options.modules.common.communication.mail = { - enable = lib.mkEnableOption "Enable mail communication tools"; - services = lib.mkOption { type = lib.types.listOf (lib.types.enum ["thunderbird" "bluemail"]); - default = ["thunderbird"]; + default = []; description = "List of mail services to enable"; }; }; - config = lib.mkIf cfg.enable { + config = { home.packages = packagesToInstall; }; } \ No newline at end of file diff --git a/modules/hm/common/default.nix b/modules/hm/common/default.nix index ccd63b0..1e4fd3f 100644 --- a/modules/hm/common/default.nix +++ b/modules/hm/common/default.nix @@ -3,6 +3,8 @@ }: { imports = [ + ./browser + ./communication/mail ./communication/teams.nix @@ -12,24 +14,20 @@ ./dev/editor/android-studio.nix ./dev/global-tools/act-github.nix ./dev/global-tools/nix.nix - ./dev/node/graphite.nix + ./dev/global-tools/cli.nix ./dev/node/node.nix ./dev/node/pm2.nix ./dev/node/prisma.nix - ./dev/node/vercel.nix ./dev/dotnet.nix ./dev/python.nix ./dev/rust.nix ./documentation/obsidian.nix - ./documentation/okular.nix - ./documentation/onlyoffice.nix - - ./driver/chrome.nix + ./documentation ./emulator - ./engine/engine.nix + ./engine #./extra/ignore-file-retriever.nix @@ -40,7 +38,6 @@ ./games/star-citizen.nix ./games/northstar.nix - ./multimedia/easyeffects.nix ./multimedia/gimp.nix ./multimedia/mpv.nix ./multimedia/obs.nix @@ -58,7 +55,7 @@ ./shell/tools.nix ./utilities/filezilla.nix - ./utilities/gitkraken.nix + ./utilities/kde-connect.nix ./utilities/scalar.nix ./utilities/stacer.nix ]; diff --git a/modules/hm/common/dev/global-tools/cli.nix b/modules/hm/common/dev/global-tools/cli.nix new file mode 100644 index 0000000..0141a82 --- /dev/null +++ b/modules/hm/common/dev/global-tools/cli.nix @@ -0,0 +1,22 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.modules.common.dev.global-tools.cli; +in +{ + options.modules.common.dev.global-tools.cli = { + + elements = lib.mkOption { + type = lib.types.listOf (lib.types.enum ["vercel" "graphite"]); + default = []; + description = "List of CLI tools to install"; + }; + }; + + config = { + home.packages = (with pkgs; + lib.optional (lib.elem "vercel" cfg.elements) nodePackages.vercel ++ + lib.optional (lib.elem "graphite" cfg.elements) graphite-cli + ); + }; +} diff --git a/modules/hm/common/dev/node/graphite.nix b/modules/hm/common/dev/node/graphite.nix deleted file mode 100644 index f481051..0000000 --- a/modules/hm/common/dev/node/graphite.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - cfg = config.modules.common.dev.node.graphite; -in -{ - options.modules.common.dev.node.graphite = { - enable = lib.mkEnableOption "Enable Graphite CLI for Node.js"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - graphite-cli - ]); - }; -} diff --git a/modules/hm/common/dev/node/vercel.nix b/modules/hm/common/dev/node/vercel.nix deleted file mode 100644 index 4876bf2..0000000 --- a/modules/hm/common/dev/node/vercel.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - cfg = config.modules.common.dev.node.vercel; -in -{ - options.modules.common.dev.node.vercel = { - enable = lib.mkEnableOption "Enable Vercel CLI for Node.js deployments"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - nodePackages.vercel - ]); - }; -} diff --git a/modules/hm/common/documentation/default.nix b/modules/hm/common/documentation/default.nix new file mode 100644 index 0000000..d27afca --- /dev/null +++ b/modules/hm/common/documentation/default.nix @@ -0,0 +1,21 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.modules.common.documentation; +in +{ + options.modules.common.documentation = { + editor = lib.mkOption { + type = lib.types.listOf (lib.types.enum ["onlyoffice" "okular"]); + default = []; + description = "List of document editors to install"; + }; + }; + + config = { + home.packages = with pkgs; ( + (lib.optional (lib.elem "onlyoffice" cfg.editor) onlyoffice-bin) ++ + (lib.optional (lib.elem "okular" cfg.editor) okular) + ); + }; +} diff --git a/modules/hm/common/documentation/okular.nix b/modules/hm/common/documentation/okular.nix deleted file mode 100644 index 1d60593..0000000 --- a/modules/hm/common/documentation/okular.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - cfg = config.modules.common.documentation.okular; -in -{ - options.modules.common.documentation.okular = { - enable = lib.mkEnableOption "Enable Okular document viewer"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - okular - ]); - }; -} diff --git a/modules/hm/common/documentation/onlyoffice.nix b/modules/hm/common/documentation/onlyoffice.nix deleted file mode 100644 index 80e4436..0000000 --- a/modules/hm/common/documentation/onlyoffice.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - cfg = config.modules.common.documentation.onlyoffice; -in -{ - options.modules.common.documentation.onlyoffice = { - enable = lib.mkEnableOption "Enable OnlyOffice document editor"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - onlyoffice-bin - ]); - }; -} diff --git a/modules/hm/common/driver/chrome.nix b/modules/hm/common/driver/chrome.nix deleted file mode 100644 index 50db2ef..0000000 --- a/modules/hm/common/driver/chrome.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - cfg = config.modules.common.driver.chrome; -in -{ - options.modules.common.driver.chrome = { - enable = lib.mkEnableOption "Enable Chrome WebDriver (chromedriver)"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - chromedriver - ]); - }; -} diff --git a/modules/hm/common/engine/default.nix b/modules/hm/common/engine/default.nix new file mode 100644 index 0000000..135a702 --- /dev/null +++ b/modules/hm/common/engine/default.nix @@ -0,0 +1,20 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.modules.common; +in +{ + options.modules.common = { + engine = lib.mkOption { + type = lib.types.listOf (lib.types.enum ["unity"]); + default = []; + description = "List of game engines to install"; + }; + }; + + config = { + home.packages = with pkgs; ( + (lib.optionals (lib.elem "unity" cfg.engine) [unityhub]) + ); + }; +} diff --git a/modules/hm/common/engine/engine.nix b/modules/hm/common/engine/engine.nix deleted file mode 100644 index 5c64a07..0000000 --- a/modules/hm/common/engine/engine.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, vars, ... }: - -let - cfg = config.modules.common.engine.unity; -in -{ - options.modules.common.engine.unity = { - enable = lib.mkEnableOption "Enable Unity Hub for managing Unity installations"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - unityhub - ]); - }; -} diff --git a/modules/hm/common/multimedia/easyeffects.nix b/modules/hm/common/multimedia/easyeffects.nix deleted file mode 100755 index 976d3f2..0000000 --- a/modules/hm/common/multimedia/easyeffects.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: - -let - cfg = config.modules.common.multimedia.easyeffects; - # Common presets from the community - perfectEq = builtins.fetchurl { - url = "https://raw.githubusercontent.com/JackHack96/EasyEffects-Presets/master/Perfect%20EQ.json"; - name = "perfect-eq.json"; - sha256 = "sha256:0cppf5kcpp2spz7y38n0xwj83i4jkgvcbp06p1l005p2vs7xs59f"; - }; -in -{ - options.modules.common.multimedia.easyeffects = { - enable = lib.mkEnableOption "Enable EasyEffects audio processing tool"; - }; - - config = lib.mkIf cfg.enable { - # Install EasyEffects - home.packages = with pkgs; [ - easyeffects - calf # Additional audio plugins - lsp-plugins # More audio plugins - ]; - - # Enable EasyEffects service - services.easyeffects = { - enable = true; - preset = "Perfect EQ"; # Default to Perfect EQ preset - }; - - # Install community presets - xdg.configFile = { - "easyeffects/output/Perfect EQ.json".source = perfectEq; - }; - }; -} diff --git a/modules/hm/common/shell/disk-usage.nix b/modules/hm/common/shell/disk-usage.nix index be6e8b1..7718d4c 100644 --- a/modules/hm/common/shell/disk-usage.nix +++ b/modules/hm/common/shell/disk-usage.nix @@ -6,11 +6,9 @@ let in { options.modules.common.shell.disk-usage = { - enable = lib.mkEnableOption "Enable Disk Usage Analyzers"; - tools = lib.mkOption { type = lib.types.listOf (lib.types.enum validTools); - default = [ "squirreldisk" ]; + default = []; description = "List of disk usage analyzers to install."; }; }; diff --git a/modules/hm/common/utilities/gitkraken.nix b/modules/hm/common/utilities/gitkraken.nix deleted file mode 100644 index fa557e2..0000000 --- a/modules/hm/common/utilities/gitkraken.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - cfg = config.modules.common.utilities.gitkraken; -in -{ - options.modules.common.utilities.gitkraken = { - enable = lib.mkEnableOption "Enable GitKraken (Git GUI client)"; - }; - - config = lib.mkIf cfg.enable { - home.packages = (with pkgs; [ - gitkraken - ]); - }; -} diff --git a/modules/hm/common/utilities/kde-connect.nix b/modules/hm/common/utilities/kde-connect.nix new file mode 100644 index 0000000..68dd37b --- /dev/null +++ b/modules/hm/common/utilities/kde-connect.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +with lib; + +let + cfg = config.modules.common.utilities.kde-connect; +in +{ + options.modules.common.utilities.kde-connect = { + enable = mkEnableOption "KDE Connect"; + indicator = mkOption { + type = types.bool; + default = true; + description = "Enable the KDE Connect tray indicator."; + }; + }; + + config = mkIf cfg.enable { + services.kdeconnect.enable = true; + services.kdeconnect.indicator = cfg.indicator; + }; +} \ No newline at end of file diff --git a/modules/hm/desktops/default.nix b/modules/hm/desktops/default.nix deleted file mode 100644 index 3916cf8..0000000 --- a/modules/hm/desktops/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - ... -}: -{ - imports = [ - ./hydenix.nix - ]; -} diff --git a/modules/hm/desktops/hydenix.nix b/modules/hm/desktops/hydenix.nix index 5229e3b..0376510 100644 --- a/modules/hm/desktops/hydenix.nix +++ b/modules/hm/desktops/hydenix.nix @@ -93,7 +93,8 @@ in # Example monitor configuration # Replace names like HDMI-A-1, DP-1, etc. with the actual names of your monitors (use `hyprctl monitors` to list) - # monitor=,@,x, + # monitor = ,,,,, + # Features can include: "primary", "no-vrr", "no-hdr", "no-gamma", "vrr", etc. # Main display # monitor=HDMI-A-1,auto,0x0,1 diff --git a/modules/hm/hosts/oak/default.nix b/modules/hm/hosts/oak/default.nix index 8f501c7..9aca276 100644 --- a/modules/hm/hosts/oak/default.nix +++ b/modules/hm/hosts/oak/default.nix @@ -28,15 +28,16 @@ gimp.enable = true; stremio.enable = true; }; - driver = { - chrome.enable = true; + browser = { + emulators = ["chrome" "firefox"]; + driver.enable = true; }; documentation = { + editor = ["onlyoffice"]; obsidian = { enable = true; backupMethod = "git-push-temp"; }; - onlyoffice.enable = true; }; dev = { editor = { @@ -49,11 +50,10 @@ global-tools = { act-github.enable = true; nix.enable = true; + cli.elements = ["vercel" "graphite"]; }; node = { enable = true; - graphite.enable = true; - vercel.enable = true; prisma.enable = true; }; python = { @@ -63,10 +63,7 @@ }; communication = { teams.enable = true; - mail = { - enable = true; - services = ["thunderbird"]; - }; + mail.services = ["thunderbird"]; }; network.tunnel = { enable = true; @@ -76,7 +73,10 @@ port = 3000; }; }; - utilities.scalar.enable = true; + utilities = { + kde-connect.enable = true; + scalar.enable = true; + }; #extra = { #ignore-file-retriever = { #enable = true; diff --git a/modules/system/common/default.nix b/modules/system/common/default.nix index 42e1f77..b0448df 100644 --- a/modules/system/common/default.nix +++ b/modules/system/common/default.nix @@ -11,29 +11,20 @@ ./games/gamescope.nix ./games/games.nix - ./hardware/gpu/amd.nix ./hardware/autologin.nix ./hardware/boot.nix + ./hardware/powersave.nix + ./networks/print/print.nix ./networks/vpn/tailscale.nix + ./nix/linux-cachyos.nix + ./nix/nix-garbage.nix + ./nix/polkit.nix + ./security/antivirus.nix + ./security/password-manager.nix ./virtualisation/containers/containers.nix - - ./linux-cachyos.nix - - ./nix-garbage.nix ]; - - # TODO: move this somewhere? - # For dolphin udisks2 permission for click mounting disks - security.polkit.extraConfig = '' - polkit.addRule(function(action, subject) { - if (action.id.indexOf("org.freedesktop.udisks2.") == 0 && - subject.isInGroup("users")) { - return polkit.Result.YES; - } - }); - ''; } diff --git a/modules/system/common/dev/dev.nix b/modules/system/common/dev/dev.nix index d5060ad..5d4231f 100755 --- a/modules/system/common/dev/dev.nix +++ b/modules/system/common/dev/dev.nix @@ -30,16 +30,6 @@ in libunwind libuuid zlib - # Add any other libraries you might need - - # Node.js dependencies - nodejs_20 - nodePackages.pnpm - # Common runtime dependencies - stdenv.cc.cc - openssl - zlib - pnpm ]; }; }; diff --git a/modules/system/common/dev/flutter.nix b/modules/system/common/dev/flutter.nix index 81c1d81..9135ce6 100755 --- a/modules/system/common/dev/flutter.nix +++ b/modules/system/common/dev/flutter.nix @@ -50,8 +50,6 @@ in [ pkgs.flutter cfg.jdkPackage - # TODO: move to its own module - pkgs.google-chrome ] ++ lib.optional cfg.withAndroid androidSdk; @@ -59,7 +57,6 @@ in environment.variables = lib.mkMerge [ { JAVA_HOME = "${cfg.jdkPackage}"; } { STUDIO_JDK = "${cfg.jdkPackage}"; } - { CHROME_EXECUTABLE = "${pkgs.google-chrome}/bin/google-chrome-stable"; } (lib.mkIf cfg.withAndroid { ANDROID_HOME = "${androidSdk}/libexec/android-sdk"; }) diff --git a/modules/system/common/dev/php.nix b/modules/system/common/dev/php.nix index f5330d6..0216333 100644 --- a/modules/system/common/dev/php.nix +++ b/modules/system/common/dev/php.nix @@ -6,16 +6,10 @@ in { options.modules.dev.php = { enable = lib.mkEnableOption "Enable PHP development environment"; - - installMethod = lib.mkOption { - type = lib.types.enum [ "hm" "sys" ]; - default = "sys"; - description = "Choose whether to install php via home-manager or directly in the environment."; - }; }; config = lib.mkIf cfg.enable { - environment.systemPackages = lib.mkIf (cfg.installMethod == "sys") (with pkgs; [ + environment.systemPackages = (with pkgs; [ php83Extensions.xdebug php83Extensions.sqlsrv php83 diff --git a/modules/system/common/games/games.nix b/modules/system/common/games/games.nix index 2d01f95..8dfa9a9 100755 --- a/modules/system/common/games/games.nix +++ b/modules/system/common/games/games.nix @@ -9,15 +9,46 @@ in steam = { compatToolsPath = lib.mkOption { - type = lib.types.str; - default = "$HOME/.steam/root/compatibilitytools.d"; - description = "Path for Steam compatibility tools"; + type = lib.types.path; + default = "${builtins.getEnv "HOME"}/.steam/root/compatibilitytools.d"; + description = "Path for Steam compatibility tools"; }; enable = lib.mkEnableOption "Enable Steam support"; }; lutris.enable = lib.mkEnableOption "Enable Lutris support"; heroic.enable = lib.mkEnableOption "Enable Heroic support"; + + gamemode = { + enable = lib.mkEnableOption "Enable GameMode support"; + enableRenice = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable renice support in GameMode"; + }; + notificationCommands = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = { + start = "notify-send 'GameMode started'"; + end = "notify-send 'GameMode ended'"; + }; + description = "Custom notification commands for GameMode start and end events"; + }; + generalSettings = lib.mkOption { + type = lib.types.attrsOf (lib.types.oneOf [ lib.types.int lib.types.bool lib.types.str ]); + default = { + inhibit_screensaver = 1; + }; + description = "General GameMode settings"; + }; + gpuSettings = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = { + apply_gpu_optimisations = "accept-responsibility"; + }; + description = "GPU-related GameMode settings"; + }; + }; }; config = lib.mkIf cfg.enable { @@ -31,8 +62,19 @@ in }; programs = lib.mkMerge [ + (lib.mkIf cfg.gamemode.enable { + gamemode = { + enable = true; + enableRenice = cfg.gamemode.enableRenice; + settings = { + general = cfg.gamemode.generalSettings; + gpu = cfg.gamemode.gpuSettings; + custom = cfg.gamemode.notificationCommands; + }; + }; + }) + (lib.mkIf cfg.steam.enable { - gamemode.enable = true; gamescope = { enable = true; capSysNice = true; diff --git a/modules/system/common/hardware/gpu/amd.nix b/modules/system/common/hardware/gpu/amd.nix deleted file mode 100644 index b4db025..0000000 --- a/modules/system/common/hardware/gpu/amd.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - cfg = config.modules.hardware.gpu.amd; -in -{ - options.modules.hardware.gpu.amd = { - enable = lib.mkEnableOption "Enable AMD GPU support with Vulkan tools"; - }; - - config = lib.mkIf cfg.enable { - - environment.systemPackages = (with pkgs; [ - vulkan-tools - ]); - }; -} diff --git a/modules/system/common/hardware/powersave.nix b/modules/system/common/hardware/powersave.nix new file mode 100644 index 0000000..61f4673 --- /dev/null +++ b/modules/system/common/hardware/powersave.nix @@ -0,0 +1,163 @@ +{ config, lib, pkgs, vars, ... }: + +let + cfg = config.modules.hardware.powersave; +in { + options.modules.hardware.powersave = { + enable = lib.mkEnableOption "Enable power saving configuration"; + + architecture = lib.mkOption { + type = lib.types.enum [ "intel" "amd" ]; + default = "amd"; + description = "Select the architecture for power saving optimizations"; + }; + + batteryHealth = { + enable = lib.mkEnableOption "Enable battery health preservation features"; + chargeThresholds = { + start = lib.mkOption { + type = lib.types.int; + default = 75; + description = "Start charging when battery falls below this percentage"; + }; + stop = lib.mkOption { + type = lib.types.int; + default = 80; + description = "Stop charging when battery reaches this percentage"; + }; + }; + }; + + disk = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + description = "List of disks for power management"; + }; + + managePowerProfiles = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Enable basic power profile management through kernel parameters. + Note: For advanced control (fan curves, lighting, etc.) use asusctl instead. + ''; + }; + + asus = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable ASUS hardware support for power management."; + }; + }; + }; + + config = lib.mkIf cfg.enable { + # Add required packages + environment.systemPackages = with pkgs; [ + powertop + acpi + ] ++ lib.optional (cfg.architecture == "amd") amdctl + ++ lib.optionals cfg.asus.enable [ asusctl supergfxctl ]; + + # Enable power management + powerManagement = { + enable = true; + cpuFreqGovernor = lib.mkDefault "powersave"; + powertop.enable = true; + }; + + # Enable TLP for advanced power management + services.tlp = { + enable = true; + settings = let + disks = lib.concatStringsSep " " cfg.disk; + diskSettings = lib.concatStringsSep " " (lib.genList (_: "128") (lib.length cfg.disk)); + in { + # CPU settings + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_BOOST_ON_BAT = 0; + + # Architecture specific settings + CPU_HWP_ON_BAT = if cfg.architecture == "amd" then "power" else "balance_performance"; + PLATFORM_PROFILE_ON_BAT = "low-power"; + + # PCIe power management + PCIE_ASPM_ON_BAT = "powersupersave"; + + # WiFi power saving + WIFI_PWR_ON_BAT = "on"; + + # Audio power saving + SOUND_POWER_SAVE_ON_BAT = 1; + + # USB autosuspend + USB_AUTOSUSPEND = 1; + USB_BLACKLIST_BTUSB = 1; + + # Disk power management + DISK_DEVICES = disks; + DISK_APM_LEVEL_ON_BAT = diskSettings; + DISK_SPINDOWN_TIMEOUT_ON_BAT = diskSettings; + + # Runtime power management + RUNTIME_PM_ON_BAT = "auto"; + + # Battery charge thresholds (for battery health) + START_CHARGE_THRESH_BAT1 = cfg.batteryHealth.chargeThresholds.start; + STOP_CHARGE_THRESH_BAT1 = cfg.batteryHealth.chargeThresholds.stop; + + # Ensure TLP applies these thresholds + RESTORE_THRESHOLDS_ON_BAT = 1; + }; + }; + + # Enable auto-cpufreq for dynamic CPU frequency scaling + services.auto-cpufreq = { + enable = true; + settings = { + battery = { + governor = "powersave"; + turbo = "never"; + }; + charger = { + governor = if cfg.architecture == "amd" then "ondemand" else "performance"; + turbo = "auto"; + }; + }; + }; + + # Kernel parameters + boot.kernelParams = + (if cfg.managePowerProfiles then [ + "mem_sleep_default=deep" + "power_supply.wakeup=disabled" + "libata.force=noncq" + "pcie_aspm=force" + ] else []) ++ + (if cfg.architecture == "amd" then [ + "amd_pstate=active" + "amd_pstate.shared_mem=1" + ] else [ + "intel_idle.max_cstate=4" + "processor.max_cstate=5" + ]); + + # Services configuration + services = { + thermald.enable = lib.mkDefault (cfg.architecture == "intel"); + power-profiles-daemon.enable = lib.mkForce (!(cfg.batteryHealth.enable || cfg.managePowerProfiles)); + upower.enable = true; + + # ASUS control services + asusd = lib.mkIf cfg.asus.enable { + enable = true; + enableUserService = true; + }; + supergfxd = lib.mkIf cfg.asus.enable { + enable = true; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/system/common/networks/print/print.nix b/modules/system/common/networks/print/print.nix new file mode 100644 index 0000000..fc91d37 --- /dev/null +++ b/modules/system/common/networks/print/print.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.modules.networks.print; +in { + options.modules.networks.print = { + enable = mkEnableOption "Print services"; + cups.enable = mkOption { + type = types.bool; + default = true; + description = "Enable CUPS (Common Unix Printing System)"; + }; + drivers = mkOption { + type = types.listOf types.package; + default = [ pkgs.cnijfilter2 ]; + description = '' + List of printer drivers to use. Defaults to [ pkgs.cnijfilter2 ], which + is an unfree package for Canon printers. + ''; + }; + }; + + config = mkIf cfg.enable { + services.printing.enable = cfg.cups.enable; + services.printing.drivers = lib.mkIf cfg.cups.enable cfg.drivers; + }; +} \ No newline at end of file diff --git a/modules/system/common/linux-cachyos.nix b/modules/system/common/nix/linux-cachyos.nix similarity index 70% rename from modules/system/common/linux-cachyos.nix rename to modules/system/common/nix/linux-cachyos.nix index d8ccc13..f9074ad 100755 --- a/modules/system/common/linux-cachyos.nix +++ b/modules/system/common/nix/linux-cachyos.nix @@ -7,17 +7,19 @@ }: let - cfg = config.modules.linux-cachyos; + cfg = config.modules.nix.linux-cachyos; in { imports = [ inputs.chaotic.nixosModules.default ]; - options.modules.linux-cachyos = { + options.modules.nix.linux-cachyos = { enable = lib.mkEnableOption "Enable Chaotic-AUR (CachyOS) support"; + enableSCX = lib.mkEnableOption "Enable SCX service when using Chaotic-AUR (CachyOS)"; }; config = lib.mkIf cfg.enable { boot.kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos; + nix.settings = { substituters = [ "https://chaotic-nyx.cachix.org" @@ -26,5 +28,7 @@ in "chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8=" ]; }; + + services.scx.enable = cfg.enableSCX; }; } diff --git a/modules/system/common/nix-garbage.nix b/modules/system/common/nix/nix-garbage.nix similarity index 91% rename from modules/system/common/nix-garbage.nix rename to modules/system/common/nix/nix-garbage.nix index 8c06729..5689556 100644 --- a/modules/system/common/nix-garbage.nix +++ b/modules/system/common/nix/nix-garbage.nix @@ -1,10 +1,10 @@ { lib, pkgs, inputs, config, ... }: let - cfg = config.modules.nix-garbage; + cfg = config.modules.nix.nix-garbage; in { - options.modules.nix-garbage = { + options.modules.nix.nix-garbage = { enable = lib.mkEnableOption "Enable automatic garbage collection for Nix"; dates = lib.mkOption { diff --git a/modules/system/common/nix/polkit.nix b/modules/system/common/nix/polkit.nix new file mode 100644 index 0000000..8ea0d5c --- /dev/null +++ b/modules/system/common/nix/polkit.nix @@ -0,0 +1,22 @@ +{ lib, config, ... }: + +let + cfg = config.modules.nix.polkit; +in +{ + options.modules.nix.polkit = { + enable = lib.mkEnableOption "Enable polkit configuration"; + }; + + config = lib.mkIf cfg.enable { + # For dolphin udisks2 permission for click mounting disks + security.polkit.extraConfig = '' + polkit.addRule(function(action, subject) { + if (action.id.indexOf("org.freedesktop.udisks2.") == 0 && + subject.isInGroup("users")) { + return polkit.Result.YES; + } + }); + ''; + }; +} diff --git a/modules/system/common/security/password-manager.nix b/modules/system/common/security/password-manager.nix new file mode 100644 index 0000000..adc2b98 --- /dev/null +++ b/modules/system/common/security/password-manager.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.modules.security; +in { + options.modules.security = { + yubikey.enable = mkEnableOption "Enable YubiKey support for password management"; + + passwordManager = { + backend = mkOption { + type = types.listOf (types.enum ["keepassxc" "bitwarden"]); + default = ["keepassxc"]; + description = "Select the password manager backend(s) to use."; + }; + }; + }; + + config = { + security.pam.u2f.enable = cfg.yubikey.enable; + + services = { + pcscd.enable = cfg.yubikey.enable; + + udev.packages = lib.optionals cfg.yubikey.enable [ + pkgs.yubikey-personalization + pkgs.yubikey-manager + ]; + }; + + environment.systemPackages = + (lib.optionals cfg.yubikey.enable [ + pkgs.yubikey-manager + pkgs.yubikey-personalization + pkgs.yubioath-flutter + pkgs.yubikey-touch-detector + pkgs.age + pkgs.age-plugin-yubikey + pkgs.pam_u2f + ]) ++ + (lib.optionals (lib.elem "keepassxc" cfg.passwordManager.backend) [ + pkgs.keepassxc + ]) ++ + (lib.optionals (lib.elem "bitwarden" cfg.passwordManager.backend) [ + pkgs.bitwarden-desktop + ]); + }; +} \ No newline at end of file diff --git a/modules/system/common/virtualisation/containers/containers.nix b/modules/system/common/virtualisation/containers/containers.nix index 5c265a6..f370664 100644 --- a/modules/system/common/virtualisation/containers/containers.nix +++ b/modules/system/common/virtualisation/containers/containers.nix @@ -7,26 +7,25 @@ }: let - cfg = config.modules.virtualisation; + cfg = config.modules.virtualisation.containers; in { - options.modules.virtualisation = { - docker = { - enable = lib.mkEnableOption "Enable Docker support"; - }; - podman = { - enable = lib.mkEnableOption "Enable podman"; + options.modules.virtualisation.containers = { + engine = lib.mkOption { + type = lib.types.listOf (lib.types.enum ["docker" "podman"]); + default = []; + description = "List of container engines to enable"; }; }; config = lib.mkMerge [ - (lib.mkIf cfg.docker.enable { + (lib.mkIf (lib.elem "docker" cfg.engine) { users.groups.docker.members = [ "${vars.user}" ]; virtualisation.docker.enable = true; environment.systemPackages = [ pkgs.docker pkgs.docker-compose ]; }) - (lib.mkIf cfg.podman.enable { + (lib.mkIf (lib.elem "podman" cfg.engine) { virtualisation.podman.enable = true; environment.systemPackages = [ pkgs.podman pkgs.podman-compose ]; diff --git a/modules/system/hosts/fern/default.nix b/modules/system/hosts/fern/default.nix index 19b4cb5..61a72c8 100644 --- a/modules/system/hosts/fern/default.nix +++ b/modules/system/hosts/fern/default.nix @@ -11,8 +11,10 @@ ]; modules = { - hardware.autologin.enable = false; - hardware.boot.enable = true; + hardware = { + autologin.enable = false; + boot.enable = true; + }; games.steam.enable = true; # fern specific modules diff --git a/modules/system/hosts/oak/default.nix b/modules/system/hosts/oak/default.nix index 50c0d89..82dcac8 100644 --- a/modules/system/hosts/oak/default.nix +++ b/modules/system/hosts/oak/default.nix @@ -5,9 +5,12 @@ ]; modules = { - nix-garbage = { - enable = true; - autoOptimiseStore = true; + nix = { + nix-garbage = { + enable = true; + autoOptimiseStore = true; + }; + polkit.enable = true; }; games = { enable = true; @@ -15,18 +18,22 @@ lutris.enable = true; }; networks = { + print.enable = true; vpn.tailscale.enable = true; }; - virtualisation.docker.enable = true; + virtualisation.containers.engine = ["docker"]; backup.syncthing = { enable = true; dirSync = "/home/${vars.user}"; subDir = "Documents"; }; - security.antivirus = { - enable = true; - engine = "clamav"; - gui.enable = true; + security = { + antivirus = { + enable = true; + engine = "clamav"; + gui.enable = true; + }; + passwordManager.backend = ["bitwarden"]; }; dev = { php.enable = true; @@ -35,5 +42,13 @@ withAndroid = true; }; }; + hardware.powersave = { + enable = true; + architecture = "amd"; + batteryHealth.enable = true; + managePowerProfiles = false; + disk = [ "nvme0n1" ]; + asus.enable = true; + }; }; }