From 33408ed45ef92e1a264830a90594812b5481eb5b Mon Sep 17 00:00:00 2001 From: tux Date: Wed, 6 May 2026 00:55:41 +0530 Subject: [PATCH] feat: setup base --- flake.lock | 431 ++++++++++++++++++++++++++++ flake.nix | 37 +++ modules/flake/flake-parts.nix | 4 + modules/flake/overlays.nix | 28 ++ modules/flake/systems.nix | 6 + modules/flake/treefmt.nix | 23 ++ modules/hm/core/hm.nix | 13 + modules/hm/core/nixpkgs.nix | 18 ++ modules/hm/desktop/lan-mouse.nix | 39 +++ modules/hm/shell/bat.nix | 5 + modules/hm/shell/btop.nix | 12 + modules/hm/shell/fastfetch.nix | 69 +++++ modules/hm/shell/fzf.nix | 8 + modules/hm/shell/git.nix | 26 ++ modules/hm/shell/lazygit.nix | 173 +++++++++++ modules/hm/shell/lsd.nix | 8 + modules/hm/shell/neovim.nix | 42 +++ modules/hm/shell/opencode.nix | 24 ++ modules/hm/shell/ripgrep.nix | 5 + modules/hm/shell/starship.nix | 52 ++++ modules/hm/shell/superfile.nix | 43 +++ modules/hm/shell/tmux.nix | 155 ++++++++++ modules/hm/shell/zoxide.nix | 9 + modules/hm/shell/zsh.nix | 27 ++ modules/hosts/sirius/config.nix | 157 ++++++++++ modules/hosts/sirius/default.nix | 23 ++ modules/hosts/sirius/hardware.nix | 48 ++++ modules/hosts/sirius/home.nix | 24 ++ modules/nixos/core/hm.nix | 37 +++ modules/nixos/core/nh.nix | 20 ++ modules/nixos/core/nix.nix | 83 ++++++ modules/nixos/core/nixpkgs.nix | 12 + modules/nixos/core/security.nix | 9 + modules/nixos/core/substituters.nix | 31 ++ modules/nixos/core/users.nix | 29 ++ 35 files changed, 1730 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 modules/flake/flake-parts.nix create mode 100644 modules/flake/overlays.nix create mode 100644 modules/flake/systems.nix create mode 100644 modules/flake/treefmt.nix create mode 100644 modules/hm/core/hm.nix create mode 100644 modules/hm/core/nixpkgs.nix create mode 100644 modules/hm/desktop/lan-mouse.nix create mode 100644 modules/hm/shell/bat.nix create mode 100644 modules/hm/shell/btop.nix create mode 100644 modules/hm/shell/fastfetch.nix create mode 100644 modules/hm/shell/fzf.nix create mode 100644 modules/hm/shell/git.nix create mode 100644 modules/hm/shell/lazygit.nix create mode 100644 modules/hm/shell/lsd.nix create mode 100644 modules/hm/shell/neovim.nix create mode 100644 modules/hm/shell/opencode.nix create mode 100644 modules/hm/shell/ripgrep.nix create mode 100644 modules/hm/shell/starship.nix create mode 100644 modules/hm/shell/superfile.nix create mode 100644 modules/hm/shell/tmux.nix create mode 100644 modules/hm/shell/zoxide.nix create mode 100644 modules/hm/shell/zsh.nix create mode 100644 modules/hosts/sirius/config.nix create mode 100644 modules/hosts/sirius/default.nix create mode 100644 modules/hosts/sirius/hardware.nix create mode 100644 modules/hosts/sirius/home.nix create mode 100644 modules/nixos/core/hm.nix create mode 100644 modules/nixos/core/nh.nix create mode 100644 modules/nixos/core/nix.nix create mode 100644 modules/nixos/core/nixpkgs.nix create mode 100644 modules/nixos/core/security.nix create mode 100644 modules/nixos/core/substituters.nix create mode 100644 modules/nixos/core/users.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2a1825a --- /dev/null +++ b/flake.lock @@ -0,0 +1,431 @@ +{ + "nodes": { + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1770019181, + "narHash": "sha256-hwsYgDnby50JNVpTRYlF3UR/Rrpt01OrxVuryF40CFY=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "77c906c0ba56aabdbc72041bf9111b565cdd6171", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1777713215, + "narHash": "sha256-8GzXDOXckDWwST8TY5DbwYFjdvQLlP7K9CLSVx6iTTo=", + "owner": "nix-community", + "repo": "disko", + "rev": "63b4e7e6cf75307c1d26ac3762b886b5b0247267", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "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" + ] + }, + "locked": { + "lastModified": 1777678872, + "narHash": "sha256-EPIFsulyon7Z1vLQq5Fk64GR8L7cQsT+IPhcsukVbgk=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "5250617bffd85403b14dbf43c3870e7f255d2c16", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1777846259, + "narHash": "sha256-jzln9xcpVcmEB1zfhJ+FIHd7/kaVHgGF+gQQHxj2fGI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "4625f26228f4f7ea3cf65eee3023359a8221fcff", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "impermanence", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1768598210, + "narHash": "sha256-kkgA32s/f4jaa4UG+2f8C225Qvclxnqs76mf8zvTVPg=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c47b2cc64a629f8e075de52e4742de688f930dc6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "inputs": { + "home-manager": "home-manager_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1769548169, + "narHash": "sha256-03+JxvzmfwRu+5JafM0DLbxgHttOQZkUtDWBmeUkN8Y=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "7b1d382faf603b6d264f58627330f9faa5cba149", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "import-tree": { + "locked": { + "lastModified": 1773693634, + "narHash": "sha256-BtZ2dtkBdSUnFPPFc+n0kcMbgaTxzFNPv2iaO326Ffg=", + "owner": "vic", + "repo": "import-tree", + "rev": "c41e7d58045f9057880b0d85e1152d6a4430dbf1", + "type": "github" + }, + "original": { + "owner": "vic", + "repo": "import-tree", + "type": "github" + } + }, + "lan-mouse": { + "inputs": { + "nixpkgs": "nixpkgs_3", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1777496383, + "narHash": "sha256-mebY9G6bvaP7F312eZZh9CFlBxwj/LfeEXVuId85x/w=", + "owner": "feschber", + "repo": "lan-mouse", + "rev": "3e7b04c1848afb2d77f802c7ddf1f5f3720c1b47", + "type": "github" + }, + "original": { + "owner": "feschber", + "repo": "lan-mouse", + "type": "github" + } + }, + "nixos-hardware": { + "locked": { + "lastModified": 1777796046, + "narHash": "sha256-bEJp/zaQApzynGRaAO62BZSz9tFikKtIHCn2yIA/s7Q=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "eeb02f6e29fc8139c0b15af5ff0fdfdc6d0d3d90", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1743014863, + "narHash": "sha256-jAIUqsiN2r3hCuHji80U7NNEafpIMBXiwKlSrjWMlpg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bd3bac8bfb542dbde7ffffb6987a1a1f9d41699f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1777805331, + "narHash": "sha256-jINoZUP2tJEBLuVoMEhJn9qWQgpriGorwlgnBc1QAPg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8cbe20ad0f64f9f9619b871dfdf57022beccef65", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1768564909, + "narHash": "sha256-Kell/SpJYVkHWMvnhqJz/8DqQg2b6PguxVWOuadbHCc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1772963539, + "narHash": "sha256-9jVDGZnvCckTGdYT53d/EfznygLskyLQXYwJLKMPsZs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9dcb002ca1690658be4a04645215baea8b95f31d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1777578337, + "narHash": "sha256-Ad49moKWeXtKBJNy2ebiTQUEgdLyvGmTeykAQ9xM+Z4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "15f4ee454b1dce334612fa6843b3e05cf546efab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1777918403, + "narHash": "sha256-7QiZv0LcW1yIOLo2LNuCQjWon1Z1r99FwK24hbtBOF4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "afc5551119aae6eab73a95c1960891cfe63204f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1770107345, + "narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "deploy-rs": "deploy-rs", + "disko": "disko", + "flake-parts": "flake-parts", + "home-manager": "home-manager", + "impermanence": "impermanence", + "import-tree": "import-tree", + "lan-mouse": "lan-mouse", + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs_4", + "nixpkgs-stable": "nixpkgs-stable", + "sops-nix": "sops-nix", + "tnvim": "tnvim", + "treefmt-nix": "treefmt-nix" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "lan-mouse", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1773025773, + "narHash": "sha256-Wik8+xApNfldpUFjPmJkPdg0RrvUPSWGIZis+A/0N1w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "3c06fdbbd36ff60386a1e590ee0cd52dcd1892bf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "sops-nix": { + "inputs": { + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1777944972, + "narHash": "sha256-VfGRo1qTBKOe3s2gOv8LSoA6Fk19PvBlwQ1ECN0Evn8=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "c591bf665727040c6cc5cb409079acb22dcce33c", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "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" + } + }, + "tnvim": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1772111181, + "narHash": "sha256-cHBFhVspigIEfCIA3lteRYrBkXTT6j9A8eyypZOOTNI=", + "owner": "tuxdotrs", + "repo": "tnvim", + "rev": "476698308f1568aa1aaa07ed5fb65dc6d92f5f2d", + "type": "github" + }, + "original": { + "owner": "tuxdotrs", + "repo": "tnvim", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1775636079, + "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "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", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..59205b5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + description = "tux's nix configurations"; + + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); + + inputs = { + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + tnvim = { + url = "github:tuxdotrs/tnvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + import-tree.url = "github:vic/import-tree"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.11-small"; + impermanence.url = "github:nix-community/impermanence"; + deploy-rs.url = "github:serokell/deploy-rs"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + sops-nix.url = "github:Mic92/sops-nix"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + lan-mouse.url = "github:feschber/lan-mouse"; + }; +} diff --git a/modules/flake/flake-parts.nix b/modules/flake/flake-parts.nix new file mode 100644 index 0000000..1c75663 --- /dev/null +++ b/modules/flake/flake-parts.nix @@ -0,0 +1,4 @@ +{ inputs, ... }: +{ + imports = [ inputs.flake-parts.flakeModules.modules ]; +} diff --git a/modules/flake/overlays.nix b/modules/flake/overlays.nix new file mode 100644 index 0000000..b9001be --- /dev/null +++ b/modules/flake/overlays.nix @@ -0,0 +1,28 @@ +{ + inputs, + withSystem, + ... +}: +{ + flake.overlays = { + modifications = final: prev: { + tnvim = inputs.tnvim.packages.${prev.stdenv.hostPlatform.system}.default; + }; + + stable-packages = final: _prev: { + stable = import inputs.nixpkgs-stable { + system = final.stdenv.hostPlatform.system; + config.allowUnfree = true; + }; + }; + }; + + perSystem = + { system, ... }: + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = builtins.attrValues inputs.self.overlays; + }; + }; +} diff --git a/modules/flake/systems.nix b/modules/flake/systems.nix new file mode 100644 index 0000000..991fba3 --- /dev/null +++ b/modules/flake/systems.nix @@ -0,0 +1,6 @@ +{ + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; +} diff --git a/modules/flake/treefmt.nix b/modules/flake/treefmt.nix new file mode 100644 index 0000000..84b30da --- /dev/null +++ b/modules/flake/treefmt.nix @@ -0,0 +1,23 @@ +{ inputs, ... }: +{ + imports = [ + inputs.treefmt-nix.flakeModule + ]; + + perSystem = + { + config, + pkgs, + system, + ... + }: + { + treefmt.config = { + projectRootFile = "flake.nix"; + flakeCheck = true; + programs = { + nixfmt.enable = true; + }; + }; + }; +} diff --git a/modules/hm/core/hm.nix b/modules/hm/core/hm.nix new file mode 100644 index 0000000..5fced0c --- /dev/null +++ b/modules/hm/core/hm.nix @@ -0,0 +1,13 @@ +{ + flake.modules.homeManager.core = + { userName, ... }: + { + programs.home-manager.enable = true; + systemd.user.startServices = "sd-switch"; + + home = { + username = "${userName}"; + homeDirectory = "/home/${userName}"; + }; + }; +} diff --git a/modules/hm/core/nixpkgs.nix b/modules/hm/core/nixpkgs.nix new file mode 100644 index 0000000..b6ca2f5 --- /dev/null +++ b/modules/hm/core/nixpkgs.nix @@ -0,0 +1,18 @@ +{ inputs, ... }: +{ + flake.modules.homeManager.core = + { + lib, + osConfig ? { }, + ... + }: + { + nixpkgs = lib.mkIf (!(osConfig.home-manager.useGlobalPkgs or false)) { + config = { + allowUnfree = true; + joypixels.acceptLicense = true; + }; + overlays = builtins.attrValues inputs.self.overlays; + }; + }; +} diff --git a/modules/hm/desktop/lan-mouse.nix b/modules/hm/desktop/lan-mouse.nix new file mode 100644 index 0000000..ab17ca9 --- /dev/null +++ b/modules/hm/desktop/lan-mouse.nix @@ -0,0 +1,39 @@ +{ inputs, ... }: +{ + flake.modules.homeManager.desktop = + { + config, + pkgs, + lib, + ... + }: + with lib; + let + cfg = config.tnix.services.lan-mouse; + in + { + imports = [ inputs.lan-mouse.homeManagerModules.default ]; + + options.tnix.services.lan-mouse = { + enable = mkEnableOption "Enable Lan-Mouse"; + + settings = mkOption { + type = (pkgs.formats.toml { }).type; + default = { }; + description = '' + TOML configuration for lan-mouse. + See for available options. + ''; + }; + }; + + config = mkIf cfg.enable { + + programs.lan-mouse = { + enable = true; + systemd = true; + settings = cfg.settings; + }; + }; + }; +} diff --git a/modules/hm/shell/bat.nix b/modules/hm/shell/bat.nix new file mode 100644 index 0000000..68f1fc9 --- /dev/null +++ b/modules/hm/shell/bat.nix @@ -0,0 +1,5 @@ +{ + flake.modules.homeManager.shell = { + programs.bat.enable = true; + }; +} diff --git a/modules/hm/shell/btop.nix b/modules/hm/shell/btop.nix new file mode 100644 index 0000000..8ab4ee1 --- /dev/null +++ b/modules/hm/shell/btop.nix @@ -0,0 +1,12 @@ +{ + flake.modules.homeManager.shell = { + programs.btop = { + enable = true; + settings = { + theme_background = false; + update_ms = 1000; + presets = "cpu:0:default mem:0:default net:0:default"; + }; + }; + }; +} diff --git a/modules/hm/shell/fastfetch.nix b/modules/hm/shell/fastfetch.nix new file mode 100644 index 0000000..20d6cdf --- /dev/null +++ b/modules/hm/shell/fastfetch.nix @@ -0,0 +1,69 @@ +{ + flake.modules.homeManager.shell = { + home.file.".config/fastfetch/config.jsonc".text = '' + { + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "none", + }, + "display": { + "separator": " ", + "key": { + "width": 18, + }, + }, + "modules": [ + { + "key": " ╭───────────╮", + "type": "custom", + }, + { + "key": " │ │\u001b[11D{#31} user", + "type": "title", + "format": "{1}", + }, + { + "key": " │ │\u001b[11D{#34} hname", + "type": "command", + "text": "hostname", + }, + { + "key": " │ │\u001b[11D{#34}󰻀 distro", + "type": "os", + }, + { + "key": " │ │\u001b[11D{#35}󰌢 kernel", + "type": "kernel", + }, + { + "key": " │ │\u001b[11D{#31} uptime", + "type": "uptime", + }, + { + "key": " │ │\u001b[11D{#32} shell", + "type": "shell", + }, + { + "key": " │ │\u001b[11D{#35} memory", + "type": "memory", + }, + { + "key": " ├───────────┤", + "type": "custom", + }, + { + "key": " │ │\u001b[11D{#39} colors", + "type": "colors", + "symbol": "circle", + }, + { + "key": " ╰───────────╯", + "type": "custom", + }, + ], + } + ''; + + programs.fastfetch.enable = true; + }; +} diff --git a/modules/hm/shell/fzf.nix b/modules/hm/shell/fzf.nix new file mode 100644 index 0000000..359d980 --- /dev/null +++ b/modules/hm/shell/fzf.nix @@ -0,0 +1,8 @@ +{ + flake.modules.homeManager.shell = { + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + }; +} diff --git a/modules/hm/shell/git.nix b/modules/hm/shell/git.nix new file mode 100644 index 0000000..fbfb8d5 --- /dev/null +++ b/modules/hm/shell/git.nix @@ -0,0 +1,26 @@ +{ + flake.modules.homeManager.shell = + { + userName, + userEmail, + ... + }: + { + programs.git = { + enable = true; + signing = { + key = "~/.ssh/id_ed25519.pub"; + signByDefault = true; + }; + settings = { + user = { + name = "${userName}"; + email = "${userEmail}"; + }; + init.defaultBranch = "main"; + commit.gpgSign = true; + gpg.format = "ssh"; + }; + }; + }; +} diff --git a/modules/hm/shell/lazygit.nix b/modules/hm/shell/lazygit.nix new file mode 100644 index 0000000..e5eecf8 --- /dev/null +++ b/modules/hm/shell/lazygit.nix @@ -0,0 +1,173 @@ +{ + flake.modules.homeManager.shell = { + programs.lazygit = { + enable = true; + settings = { + gui = { + showIcons = true; + nerdFontsVersion = "3"; + }; + customCommands = [ + { + key = ""; + description = "AI-powered conventional commit"; + context = "global"; + command = "git commit -m \"{{.Form.CommitMsg}}\""; + loadingText = "Generating commit messages..."; + prompts = [ + { + type = "menu"; + key = "Type"; + title = "Type of change"; + options = [ + { + name = "AI defined"; + description = "Let AI analyze and determine the best commit type"; + value = "ai-defined"; + } + { + name = "build"; + description = "Changes that affect the build system or external dependencies"; + value = "build"; + } + { + name = "feat"; + description = "A new feature"; + value = "feat"; + } + { + name = "fix"; + description = "A bug fix"; + value = "fix"; + } + { + name = "chore"; + description = "Other changes that don't modify src or test files"; + value = "chore"; + } + { + name = "ci"; + description = "Changes to CI configuration files and scripts"; + value = "ci"; + } + { + name = "docs"; + description = "Documentation only changes"; + value = "docs"; + } + { + name = "perf"; + description = "A code change that improves performance"; + value = "perf"; + } + { + name = "refactor"; + description = "A code change that neither fixes a bug nor adds a feature"; + value = "refactor"; + } + { + name = "revert"; + description = "Reverts a previous commit"; + value = "revert"; + } + { + name = "style"; + description = "Changes that do not affect the meaning of the code"; + value = "style"; + } + { + name = "test"; + description = "Adding missing tests or correcting existing tests"; + value = "test"; + } + ]; + } + { + type = "menuFromCommand"; + title = "AI Generated Commit Messages"; + key = "CommitMsg"; + command = '' + bash -c " + # Check for staged changes + diff=\$(git diff --cached | head -n 10) + if [ -z \"\$diff\" ]; then + echo \"No changes in staging. Add changes first.\" + exit 1 + fi + + SELECTED_TYPE=\"{{.Form.Type}}\" + COMMITS_TO_SUGGEST=8 + + opencode run -m \"google/gemini-2.5-flash-lite\" \" + You are an expert at writing Git commits. Your job is to write commit messages that follow the Conventional Commits format. + + The user has selected: \$SELECTED_TYPE + + Your task is to: + 1. Analyze the code changes + 2. Determine the most appropriate commit type (if user selected 'ai-defined') + 3. Determine an appropriate scope (component/area affected) + 4. Decide if this is a breaking change + 5. Write clear, concise commit messages + + Available commit types: + - feat: A new feature + - fix: A bug fix + - docs: Documentation only changes + - style: Changes that do not affect the meaning of the code + - refactor: A code change that neither fixes a bug nor adds a feature + - perf: A code change that improves performance + - test: Adding missing tests or correcting existing tests + - build: Changes that affect the build system or external dependencies + - ci: Changes to CI configuration files and scripts + - chore: Other changes that don't modify src or test files + - revert: Reverts a previous commit + + Follow these guidelines: + - Structure: (): + - If user selected 'ai-defined', analyze the changes and pick the most suitable type + - If user selected a specific type, use that type: \$SELECTED_TYPE + - Add scope in parentheses if applicable (e.g., auth, api, ui, config) + - Use exclamation mark (!) after type/scope for breaking changes: type(scope)!: description + - Use lowercase for description (except proper nouns) + - Use imperative mood (\\\"add\\\", not \\\"added\\\") + - Keep description under 50 characters when possible + - No period at the end of subject line + + Examples: + - feat(auth): add OAuth login support + - fix(api): handle null response in user endpoint + - docs(readme): update installation instructions + - style(ui): improve button spacing consistency + - refactor(database): simplify query builder logic + - test(auth): add unit tests for login flow + - build(deps): upgrade React to version 18 + - ci(github): fix deployment workflow + - chore(config): update ESLint rules + - perf(api)!: optimize database queries + + IMPORTANT: + - Generate exactly \$COMMITS_TO_SUGGEST different commit message options + - If user selected 'ai-defined', you can use different types for different options + - If user selected a specific type, all messages must use that type + - Only return commit messages, no explanations + - Do not use markdown code blocks + - One message per line + + Previous commits for context: + \$(git log --oneline -10) + + Changes to analyze: + \$(git diff --cached --stat) + \$(git diff --cached) + \" + " + ''; + } + ]; + } + ]; + }; + }; + }; +} diff --git a/modules/hm/shell/lsd.nix b/modules/hm/shell/lsd.nix new file mode 100644 index 0000000..6d26f74 --- /dev/null +++ b/modules/hm/shell/lsd.nix @@ -0,0 +1,8 @@ +{ + flake.modules.homeManager.shell = { + programs.lsd = { + enable = true; + enableZshIntegration = true; + }; + }; +} diff --git a/modules/hm/shell/neovim.nix b/modules/hm/shell/neovim.nix new file mode 100644 index 0000000..f1fb045 --- /dev/null +++ b/modules/hm/shell/neovim.nix @@ -0,0 +1,42 @@ +{ + flake.modules.homeManager.shell = + { pkgs, ... }: + { + home.file = { + ".config/nvim" = { + recursive = true; + source = "${pkgs.tnvim}"; + }; + }; + + programs = { + neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + }; + }; + + home = { + packages = with pkgs; [ + gcc + neovide + + # nix + nil # Language Server + statix # Lints and suggestions + deadnix # Find and remove unused + alejandra # Code Formatter + + # lua + luarocks + + # ts + typescript + + gdu + ripgrep + ]; + }; + }; +} diff --git a/modules/hm/shell/opencode.nix b/modules/hm/shell/opencode.nix new file mode 100644 index 0000000..f397e6b --- /dev/null +++ b/modules/hm/shell/opencode.nix @@ -0,0 +1,24 @@ +{ + flake.modules.homeManager.shell = { + programs.opencode = { + enable = true; + tui = { + theme = "system"; + }; + settings = { + provider = { + google = { + options = { + apiKey = "{file:/run/secrets/gemini_api_key}"; + }; + }; + openrouter = { + options = { + apiKey = "{file:/run/secrets/open_router_api_key}"; + }; + }; + }; + }; + }; + }; +} diff --git a/modules/hm/shell/ripgrep.nix b/modules/hm/shell/ripgrep.nix new file mode 100644 index 0000000..89297d5 --- /dev/null +++ b/modules/hm/shell/ripgrep.nix @@ -0,0 +1,5 @@ +{ + flake.modules.homeManager.shell = { + programs.ripgrep.enable = true; + }; +} diff --git a/modules/hm/shell/starship.nix b/modules/hm/shell/starship.nix new file mode 100644 index 0000000..71ee023 --- /dev/null +++ b/modules/hm/shell/starship.nix @@ -0,0 +1,52 @@ +{ + flake.modules.homeManager.shell = { + programs.starship = { + enable = true; + settings = { + format = "$os$hostname$directory$rust$golang$solidity$nodejs(bold blue)$git_branch$git_status[❯](bold yellow)[❯](bold purple)[❯](bold blue) "; + scan_timeout = 60; + add_newline = false; + line_break.disabled = true; + + os = { + format = "[$symbol  ]($style)"; + style = "bold green"; + disabled = false; + symbols.NixOS = "󰊠"; + symbols.Linux = "󰊠"; + symbols.Arch = "󰣇"; + symbols.Ubuntu = "󰕈"; + }; + directory = { + format = "[$path]($style)[$read_only ]($read_only_style)"; + read_only = " 󰌾"; + style = "bold blue"; + }; + git_branch.format = "[$symbol$branch]($style) "; + hostname = { + ssh_only = false; + format = "[$ssh_symbol$hostname]($style) "; + style = "bold green"; + ssh_symbol = "󰇧 "; + disabled = false; + }; + rust = { + format = "[$symbol]($style)"; + symbol = " "; + }; + golang = { + format = "[$symbol]($style)"; + symbol = " "; + }; + solidity = { + format = "[$symbol]($style)"; + symbol = "󰡪 "; + }; + nodejs = { + format = "[$symbol]($style)"; + symbol = "󰎙 "; + }; + }; + }; + }; +} diff --git a/modules/hm/shell/superfile.nix b/modules/hm/shell/superfile.nix new file mode 100644 index 0000000..bf55632 --- /dev/null +++ b/modules/hm/shell/superfile.nix @@ -0,0 +1,43 @@ +{ + flake.modules.homeManager.shell = { + programs.superfile = { + enable = true; + settings = { + theme = "poimandres"; + editor = ""; + dir_editor = ""; + auto_check_update = false; + cd_on_quit = false; + default_open_file_preview = true; + show_image_preview = true; + show_panel_footer_info = true; + default_directory = "~"; + file_size_use_si = false; + default_sort_type = 0; + sort_order_reversed = false; + case_sensitive_sort = false; + shell_close_on_success = false; + debug = false; + ignore_missing_fields = false; + nerdfont = true; + transparent_background = true; + file_preview_width = 0; + code_previewer = "bat"; + sidebar_width = 20; + border_top = "─"; + border_bottom = "─"; + border_left = "│"; + border_right = "│"; + border_top_left = "╭"; + border_top_right = "╮"; + border_bottom_left = "╰"; + border_bottom_right = "╯"; + border_middle_left = "├"; + border_middle_right = "┤"; + metadata = true; + zoxide_support = true; + enable_md5_checksum = false; + }; + }; + }; +} diff --git a/modules/hm/shell/tmux.nix b/modules/hm/shell/tmux.nix new file mode 100644 index 0000000..4593cdd --- /dev/null +++ b/modules/hm/shell/tmux.nix @@ -0,0 +1,155 @@ +{ + flake.modules.homeManager.shell = + { pkgs, ... }: + let + bg = "default"; + fg = "default"; + bg2 = "brightblack"; + fg2 = "white"; + color = c: "#{@${c}}"; + + indicator = + let + accent = color "indicator_color"; + content = "  "; + in + "#[reverse,fg=${accent}]#{?client_prefix,${content},}"; + + current_window = + let + accent = color "main_accent"; + index = "#[reverse,fg=${accent},bg=${fg}] #I "; + name = "#[fg=${bg2},bg=${fg2}] #W "; + # flags = "#{?window_flags,#{window_flags}, }"; + in + "${index}${name}"; + + window_status = + let + accent = color "window_color"; + index = "#[reverse,fg=${accent},bg=${fg}] #I "; + name = "#[fg=${bg2},bg=${fg2}] #W "; + # flags = "#{?window_flags,#{window_flags}, }"; + in + "${index}${name}"; + + battery = + let + percentage = pkgs.writeShellScript "percentage" ( + if pkgs.stdenv.isDarwin then + '' + echo $(pmset -g batt | grep -o "[0-9]\+%" | tr '%' ' ') + '' + else + '' + path="/org/freedesktop/UPower/devices/DisplayDevice" + echo $(${pkgs.upower}/bin/upower -i $path | grep -o "[0-9]\+%" | tr '%' ' ') + '' + ); + state = pkgs.writeShellScript "state" ( + if pkgs.stdenv.isDarwin then + '' + echo $(pmset -g batt | awk '{print $4}') + '' + else + '' + path="/org/freedesktop/UPower/devices/DisplayDevice" + echo $(${pkgs.upower}/bin/upower -i $path | grep state | awk '{print $2}') + '' + ); + icon = pkgs.writeShellScript "icon" '' + percentage=$(${percentage}) + state=$(${state}) + if [ "$state" == "charging" ] || [ "$state" == "fully-charged" ]; then echo "󰂄" + elif [ $percentage -ge 75 ]; then echo "󱊣" + elif [ $percentage -ge 50 ]; then echo "󱊢" + elif [ $percentage -ge 25 ]; then echo "󱊡" + elif [ $percentage -ge 0 ]; then echo "󰂎" + fi + ''; + color = pkgs.writeShellScript "color" '' + percentage=$(${percentage}) + state=$(${state}) + if [ "$state" == "charging" ] || [ "$state" == "fully-charged" ]; then echo "green" + elif [ $percentage -ge 75 ]; then echo "green" + elif [ $percentage -ge 50 ]; then echo "${fg2}" + elif [ $percentage -ge 30 ]; then echo "yellow" + elif [ $percentage -ge 0 ]; then echo "red" + fi + ''; + in + "#[fg=#(${color})]#(${icon}) #[fg=${fg}]#(${percentage})%"; + + pwd = + let + accent = color "main_accent"; + icon = "#[fg=${accent}] "; + format = "#[fg=${fg}]#{b:pane_current_path}"; + in + "${icon}${format}"; + + git = + let + icon = pkgs.writeShellScript "branch" '' + git -C "$1" branch && echo " " + ''; + branch = pkgs.writeShellScript "branch" '' + git -C "$1" rev-parse --abbrev-ref HEAD + ''; + in + "#[fg=magenta]#(${icon} #{pane_current_path})#(${branch} #{pane_current_path})"; + + separator = "#[fg=${fg}]|"; + in + { + programs.tmux = { + enable = true; + baseIndex = 1; + escapeTime = 0; + mouse = true; + extraConfig = '' + set-option -sa terminal-overrides ",xterm*:Tc" + set-option -g status-position top + unbind r + bind r source-file ~/.config/tmux/tmux.conf + + # remap prefix from C-b to C-Space + # unbind C-b + # set -g prefix C-Space + # bind C-Space send-prefix + + # split panes using | and - + unbind '"' + unbind % + bind | split-window -h + bind - split-window -v + + # Start windows and panes at 1, not 0 + set -g base-index 1 + set -g pane-base-index 1 + set-window-option -g pane-base-index 1 + set-option -g renumber-windows on + + # switch panes using Alt-arrow without prefix + bind -n M-Left select-pane -L + bind -n M-Right select-pane -R + bind -n M-Up select-pane -U + bind -n M-Down select-pane -D + + set-option -g default-terminal "screen-256color" + set-option -g status-right-length 100 + set-option -g @indicator_color "yellow" + set-option -g @window_color "magenta" + set-option -g @main_accent "blue" + set-option -g pane-active-border fg=black + set-option -g pane-border-style fg=black + set-option -g status-style "bg=${bg} fg=${fg}" + set-option -g status-left "${indicator}" + set-option -g status-right "${git} ${pwd} ${separator} ${battery}" + set-option -g window-status-current-format "${current_window}" + set-option -g window-status-format "${window_status}" + set-option -g window-status-separator "" + ''; + }; + }; +} diff --git a/modules/hm/shell/zoxide.nix b/modules/hm/shell/zoxide.nix new file mode 100644 index 0000000..42df138 --- /dev/null +++ b/modules/hm/shell/zoxide.nix @@ -0,0 +1,9 @@ +{ + flake.modules.homeManager.shell = { + programs.zoxide = { + enable = true; + options = [ "--cmd cd" ]; + enableZshIntegration = true; + }; + }; +} diff --git a/modules/hm/shell/zsh.nix b/modules/hm/shell/zsh.nix new file mode 100644 index 0000000..e751b1b --- /dev/null +++ b/modules/hm/shell/zsh.nix @@ -0,0 +1,27 @@ +{ lib, ... }: +{ + flake.modules.homeManager.shell = + { pkgs, ... }: + { + programs.zsh = { + enable = true; + history = { + append = true; + share = true; + expireDuplicatesFirst = true; + ignoreDups = true; + size = 1000000; + save = 1000000; + path = "$HOME/.local/share/zsh/.zsh_history"; + }; + syntaxHighlighting.enable = true; + autosuggestion.enable = true; + initContent = '' + ${lib.getExe pkgs.fastfetch} + bindkey "^A" vi-beginning-of-line + bindkey "^E" vi-end-of-line + bindkey '^R' fzf-history-widget + ''; + }; + }; +} diff --git a/modules/hosts/sirius/config.nix b/modules/hosts/sirius/config.nix new file mode 100644 index 0000000..420dc5b --- /dev/null +++ b/modules/hosts/sirius/config.nix @@ -0,0 +1,157 @@ +{ + flake.modules.nixos.sirius = + { + config, + lib, + pkgs, + hostName, + userName, + userEmail, + ... + }: + { + # --- Boot --- + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + kernelPackages = pkgs.linuxKernel.packages.linux_zen; + kernelParams = [ "nvidia-drm.modeset=1" ]; + }; + + # --- Networking --- + networking = { + hostName = hostName; + networkmanager = { + enable = true; + wifi.backend = "iwd"; + }; + wireless.iwd = { + enable = true; + settings = { + Network = { + EnableIPv6 = true; + }; + Settings = { + AutoConnect = true; + }; + }; + }; + firewall.enable = false; + }; + + # --- Hardware / GPU --- + hardware = { + graphics = { + enable = true; + enable32Bit = true; + }; + nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.stable; + modesetting.enable = true; + open = false; + nvidiaSettings = true; + }; + + enableAllFirmware = true; + usb-modeswitch.enable = true; + }; + + services.xserver.videoDrivers = [ "nvidia" ]; + + # --- Locale --- + time.timeZone = "Asia/Kolkata"; + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = lib.genAttrs [ + "LC_ADDRESS" + "LC_IDENTIFICATION" + "LC_MEASUREMENT" + "LC_MONETARY" + "LC_NAME" + "LC_NUMERIC" + "LC_PAPER" + "LC_TELEPHONE" + "LC_TIME" + ] (_: "en_IN"); + }; + + # --- Desktop --- + services = { + displayManager.ly.enable = true; + desktopManager.plasma6.enable = true; + }; + + # --- Fonts --- + fonts.packages = with pkgs.nerd-fonts; [ + fira-code + jetbrains-mono + bigblue-terminal + ]; + + # --- Audio --- + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + pulse.enable = true; + }; + + # --- SSH --- + services.openssh = { + enable = true; + startWhenNeeded = true; + allowSFTP = true; + settings = { + PermitRootLogin = "no"; + PasswordAuthentication = false; + KbdInteractiveAuthentication = false; + AuthenticationMethods = "publickey"; + PubkeyAuthentication = "yes"; + UsePAM = false; + UseDns = false; + X11Forwarding = false; + ClientAliveCountMax = 5; + ClientAliveInterval = 60; + + KexAlgorithms = [ + "curve25519-sha256" + "curve25519-sha256@libssh.org" + "diffie-hellman-group16-sha512" + "diffie-hellman-group18-sha512" + "sntrup761x25519-sha512@openssh.com" + "diffie-hellman-group-exchange-sha256" + "mlkem768x25519-sha256" + "sntrup761x25519-sha512" + ]; + Macs = [ + "hmac-sha2-512-etm@openssh.com" + "hmac-sha2-256-etm@openssh.com" + "umac-128-etm@openssh.com" + ]; + }; + }; + + # --- Programs --- + programs.firefox.enable = true; + + # --- Packages --- + environment.systemPackages = with pkgs; [ + neovim + discord + pciutils + brave + zed-editor + usbutils + ]; + + # !!! DO NOT CHANGE THIS !!! + # This should match the version used at initial install. + system.stateVersion = "26.05"; + }; +} diff --git a/modules/hosts/sirius/default.nix b/modules/hosts/sirius/default.nix new file mode 100644 index 0000000..b77e9ac --- /dev/null +++ b/modules/hosts/sirius/default.nix @@ -0,0 +1,23 @@ +{ + inputs, + config, + ... +}: +let + hostName = "sirius"; + userName = "tux"; + userEmail = "t@tux.rs"; + system = "x86_64-linux"; + unstable = true; + nixpkgs = if unstable then inputs.nixpkgs else inputs.nixpkgs-stable; +in +{ + flake.nixosConfigurations."${hostName}" = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { inherit hostName userName userEmail; }; + modules = [ + config.flake.modules.nixos.core + config.flake.modules.nixos.${hostName} + ]; + }; +} diff --git a/modules/hosts/sirius/hardware.nix b/modules/hosts/sirius/hardware.nix new file mode 100644 index 0000000..484b468 --- /dev/null +++ b/modules/hosts/sirius/hardware.nix @@ -0,0 +1,48 @@ +{ + flake.modules.nixos.sirius = + { + config, + lib, + ... + }: + { + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/d856ed98-6841-4cbf-89be-e08c6f48b9ea"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/7FE1-55C5"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" + ]; + }; + + swapDevices = [ { device = "/dev/disk/by-uuid/69794aa5-51a9-4816-8d45-7791505165d4"; } ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp10s0f3u2i2.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; +} diff --git a/modules/hosts/sirius/home.nix b/modules/hosts/sirius/home.nix new file mode 100644 index 0000000..df8fc01 --- /dev/null +++ b/modules/hosts/sirius/home.nix @@ -0,0 +1,24 @@ +{ config, ... }: +{ + flake.modules.homeManager.sirius = { + imports = with config.flake.modules.homeManager; [ + desktop + ]; + + tnix.services.lan-mouse = { + enable = true; + settings = { + clients = [ + { + position = "right"; + hostname = "canopus"; + activate_on_startup = true; + ips = [ "192.168.8.2" ]; + } + ]; + }; + }; + + home.stateVersion = "26.05"; + }; +} diff --git a/modules/nixos/core/hm.nix b/modules/nixos/core/hm.nix new file mode 100644 index 0000000..1f58bc1 --- /dev/null +++ b/modules/nixos/core/hm.nix @@ -0,0 +1,37 @@ +{ inputs, config, ... }: +{ + flake.modules.nixos.core = + { + hostName, + userName, + userEmail, + ... + }: + { + imports = [ + inputs.home-manager.nixosModules.home-manager + ]; + + home-manager = { + backupFileExtension = "bak"; + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { + inherit + inputs + hostName + userName + userEmail + ; + }; + + users.${userName} = { + imports = [ + config.flake.modules.homeManager.core + config.flake.modules.homeManager.shell + config.flake.modules.homeManager.${hostName} + ]; + }; + }; + }; +} diff --git a/modules/nixos/core/nh.nix b/modules/nixos/core/nh.nix new file mode 100644 index 0000000..5205e6d --- /dev/null +++ b/modules/nixos/core/nh.nix @@ -0,0 +1,20 @@ +{ + flake.modules.nixos.core = + { + config, + userName, + ... + }: + { + programs.nh = { + enable = true; + + clean = { + enable = !config.nix.gc.automatic; + dates = "weekly"; + }; + + flake = "/home/${userName}/Projects/nixos-config"; + }; + }; +} diff --git a/modules/nixos/core/nix.nix b/modules/nixos/core/nix.nix new file mode 100644 index 0000000..237b976 --- /dev/null +++ b/modules/nixos/core/nix.nix @@ -0,0 +1,83 @@ +{ + flake.modules.nixos.core = + { userName, ... }: + { + nix = { + channel.enable = false; + + gc = { + automatic = true; + options = "--delete-older-than 7d"; + dates = "weekly"; + persistent = true; + }; + + optimise.automatic = true; + + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + + max-jobs = "auto"; + + # Make legacy nix commands use the XDG base directories instead of creating directories in $HOME. + use-xdg-base-directories = true; + + # The maximum number of parallel TCP connections used to fetch files from binary caches and by other downloads. + # It defaults to 25. 0 means no limit. + http-connections = 128; + + # This option defines the maximum number of substitution jobs that Nix will try to run in + # parallel. The default is 16. The minimum value one can choose is 1 and lower values will be + # interpreted as 1. + max-substitution-jobs = 128; + + # The number of lines of the tail of the log to show if a build fails. + log-lines = 25; + + # When free disk space in /nix/store drops below min-free during a build, Nix performs a + # garbage-collection until max-free bytes are available or there is no more garbage. + # A value of 0 (the default) disables this feature. + min-free = 128000000; # 128 MB + max-free = 1000000000; # 1 GB + + # Prevent garbage collection from altering nix-shells managed by nix-direnv + # https://github.com/nix-community/nix-direnv#installation + keep-outputs = true; + keep-derivations = true; + + # If set to true, Nix will keep building derivations even if some fail. The default is false. + keep-going = true; + + # Automatically detect files in the store that have identical contents, and replaces + # them with hard links to a single copy. This saves disk space. + auto-optimise-store = true; + + # Whether to warn about dirty Git/Mercurial trees. + warn-dirty = false; + + # The timeout (in seconds) for establishing connections in the binary cache substituter. + # It corresponds to curl’s –connect-timeout option. A value of 0 means no limit. + connect-timeout = 5; + + # Allow the use of cachix + trusted-users = [ + "root" + "${userName}" + ]; + allowed-users = [ + "root" + "${userName}" + ]; + + builders-use-substitutes = true; + + # If set to true, Nix will fall back to building from source if a binary substitute + # fails. This is equivalent to the –fallback flag. The default is false. + fallback = true; + }; + }; + }; +} diff --git a/modules/nixos/core/nixpkgs.nix b/modules/nixos/core/nixpkgs.nix new file mode 100644 index 0000000..ba594b6 --- /dev/null +++ b/modules/nixos/core/nixpkgs.nix @@ -0,0 +1,12 @@ +{ inputs, ... }: +{ + flake.modules.nixos.core = { + nixpkgs = { + config = { + allowUnfree = true; + joypixels.acceptLicense = true; + }; + overlays = builtins.attrValues inputs.self.overlays; + }; + }; +} diff --git a/modules/nixos/core/security.nix b/modules/nixos/core/security.nix new file mode 100644 index 0000000..391f5fc --- /dev/null +++ b/modules/nixos/core/security.nix @@ -0,0 +1,9 @@ +{ + flake.modules.nixos.core = + { pkgs, ... }: + { + security = { + sudo.wheelNeedsPassword = false; + }; + }; +} diff --git a/modules/nixos/core/substituters.nix b/modules/nixos/core/substituters.nix new file mode 100644 index 0000000..ce3b620 --- /dev/null +++ b/modules/nixos/core/substituters.nix @@ -0,0 +1,31 @@ +{ + flake.modules.nixos.core = { + nix.settings = { + substituters = [ + "https://cache.nixos.org?priority=10" + "https://anyrun.cachix.org" + "https://fufexan.cachix.org" + "https://helix.cachix.org" + "https://hyprland.cachix.org" + "https://nix-community.cachix.org" + "https://nix-gaming.cachix.org" + "https://yazi.cachix.org" + "https://nix-on-droid.cachix.org" + "https://lan-mouse.cachix.org" + ]; + trusted-substituters = [ "https://nix-on-droid.cachix.org" ]; + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" + "fufexan.cachix.org-1:LwCDjCJNJQf5XD2BV+yamQIMZfcKWR9ISIFy5curUsY=" + "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" + "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k=" + "nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU=" + "lan-mouse.cachix.org-1:KlE2AEZUgkzNKM7BIzMQo8w9yJYqUpor1CAUNRY6OyM=" + ]; + }; + }; +} diff --git a/modules/nixos/core/users.nix b/modules/nixos/core/users.nix new file mode 100644 index 0000000..1a2a8c6 --- /dev/null +++ b/modules/nixos/core/users.nix @@ -0,0 +1,29 @@ +{ + flake.modules.nixos.core = + { + pkgs, + userName, + userEmail, + ... + }: + { + programs.zsh.enable = true; + + users = { + mutableUsers = false; + defaultUserShell = pkgs.zsh; + users.${userName} = { + initialPassword = userName; + isNormalUser = true; + extraGroups = [ + "networkmanager" + "wheel" + "storage" + ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D ${userEmail}" + ]; + }; + }; + }; +}