NixOS configuration 🪄

♻️✨ refactored shell environment ++ added tangled format workflow

Signed-off-by: Xaiya Schumin <d.schumin@proton.me>

+195 -33
+1 -1
.envrc
··· 3 3 4 4 # now we want to load the flake environment 5 5 use flake 6 - fi 6 + fi
+13
.tangled/workflows/format.yaml
··· 1 + # Format and lint files 2 + 3 + when: 4 + - event: ["push", "manual"] 5 + branch: ["main"] 6 + - event: ["pull_request"] 7 + branch: ["main"] 8 + 9 + steps: 10 + - name: "Enter development environment" 11 + command: "nix develop ." 12 + - name: "check code (with nix fmt)" 13 + command: "nix fmt"
+1 -18
home/default.nix
··· 1 1 { 2 2 lib, 3 - config, 4 3 self, 5 - inputs', 6 - system, 7 4 inputs, 8 5 ... 9 6 }: 10 - let 11 - inherit (lib.attrsets) genAttrs; 12 - in 13 7 { 14 8 15 9 imports = [ inputs.home-manager.nixosModules.home-manager ]; ··· 21 15 useGlobalPkgs = true; 22 16 backupFileExtension = "bak"; 23 17 24 - users = genAttrs config.sylveon.system.users (name: { 25 - imports = [ ./${name} ]; 26 - }); 27 - 28 - extraSpecialArgs = { 29 - inherit 30 - self 31 - inputs 32 - inputs' 33 - system 34 - ; 35 - }; 18 + extraSpecialArgs = { }; 36 19 37 20 sharedModules = [ "${self}/modules/home/default.nix" ]; 38 21 };
+3 -2
home/semiko/packages.nix
··· 1 - { pkgs, ... }: { 1 + { pkgs, ... }: 2 + { 2 3 home.packages = [ 3 4 pkgs.vim 4 5 ]; 5 - } 6 + }
+5 -1
home/xaiya/packages.nix
··· 1 1 # Packages that are not configurable/are not configured will land here 2 - { pkgs, inputs', osConfig, ... }: 2 + { 3 + pkgs, 4 + inputs', 5 + ... 6 + }: 3 7 { 4 8 # TODO: generalized home.packages (extra packages) ? 5 9 home.packages = [
+3
modules/base/default.nix
··· 1 + { 2 + 3 + }
+18
modules/flake/args.nix
··· 1 + { inputs, ... }: 2 + { 3 + # This flake, currently just uses pure nixOS systems 4 + # set the system flake output here 5 + systems = [ "x86_64-linux" ]; 6 + 7 + perSystem = 8 + { system, ... }: 9 + { 10 + # control how packages are built within the flake 11 + _module.args.pkgs = import inputs.nixpkgs { 12 + inherit system; 13 + 14 + config.allowUnfree = true; 15 + overlays = [ ]; 16 + }; 17 + }; 18 + }
+4 -1
modules/flake/default.nix
··· 3 3 ../../systems 4 4 5 5 ./lib # The library used by our configuration 6 + ./shell # Shell environment for this configuration 7 + 8 + ./args.nix # Arguments given to this flake 6 9 ]; 7 - } 10 + }
+2 -4
modules/flake/lib/default.nix
··· 1 - { 2 - ... 3 - }: { 1 + _: { 4 2 # TODO: add more based on need 5 - } 3 + }
+29
modules/flake/shell/default.nix
··· 1 + { 2 + # include the formatter for this configuration 3 + imports = [ ./formatter.nix ]; 4 + 5 + perSystem = 6 + { 7 + pkgs, 8 + inputs', 9 + config, 10 + ... 11 + }: 12 + { 13 + devShells.default = pkgs.mkShellNoCC { 14 + name = "dotfiles"; 15 + meta.description = "development environment for this flake"; 16 + 17 + inputsFrom = [ config.formatter ]; 18 + 19 + DIRENV_LOG_FORMAT = ""; 20 + 21 + packages = [ 22 + pkgs.gitMinimal # git is needed for flake based configurations 23 + inputs'.agenix-rekey.packages.default # manging secrets 24 + config.formatter # nix formatter 25 + pkgs.nix-output-monitor # detailed diff view between generations 26 + ]; 27 + }; 28 + }; 29 + }
+108
modules/flake/shell/formatter.nix
··· 1 + { lib, ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + { 6 + # The nix formatter checks the files instead of formating them 7 + # The formatter is put into a workflow at .tangled/workflows/format.yaml 8 + 9 + formatter = pkgs.treefmt.withConfig { 10 + runtimeInputs = with pkgs; [ 11 + nixfmt # nix formating tool 12 + deadnix # find and remove unused nix files 13 + statix # Lints and suggestions for the nix programming language 14 + shellcheck # shell script analysis tool 15 + shfmt # format .sh files 16 + taplo # TOML toolkit 17 + yamlfmt # format .yaml or yml files 18 + 19 + # useful script for statix commands to work 20 + # https://github.com/isabelroses/dotfiles/blob/23c7db61455348653703d32ffdc2135fd045f6b8/modules/flake/programs/formatter.nix#L22C1-L26C14 21 + (writeShellScriptBin "statix-check" '' 22 + for file in "$@"; do 23 + ${lib.getExe statix} check "$file" 24 + done 25 + '') 26 + ]; 27 + 28 + settings = { 29 + on-unmatched = "info"; 30 + tree-root-file = "flake.nix"; 31 + 32 + excludes = [ 33 + "secrets/*" 34 + "assets/*" 35 + ]; 36 + 37 + formatter = { 38 + nixfmt = { 39 + command = "nixfmt"; 40 + options = "-c"; # Check files instead of formating 41 + 42 + includes = [ "*.nix" ]; 43 + }; 44 + 45 + deadnix = { 46 + command = "deadnix"; 47 + 48 + # Warn if there was any dead nix files 49 + options = [ "--fail" ]; 50 + includes = [ "*.nix" ]; 51 + }; 52 + 53 + statix = { 54 + command = "statix-check"; 55 + includes = [ "*.nix" ]; 56 + }; 57 + 58 + shellcheck = { 59 + command = "shellcheck"; 60 + 61 + includes = [ 62 + "*.sh" 63 + "*.bash" 64 + "*.envrc" 65 + "*.envrc.*" 66 + ]; 67 + }; 68 + 69 + shfmt = { 70 + command = "shfmt"; 71 + options = [ 72 + "-s" # simplify the code 73 + "-d" # error out of the changes 74 + "-i" 75 + "2" # indent files for 2 spaces 76 + ]; 77 + 78 + includes = [ 79 + "*.sh" 80 + "*.bash" 81 + "*.envrc" 82 + "*.envrc.*" 83 + ]; 84 + }; 85 + 86 + taplo = { 87 + command = "taplo"; 88 + options = "error"; 89 + includes = [ "*.toml" ]; 90 + }; 91 + 92 + yamlfmt = { 93 + command = "yamlfmt"; 94 + options = [ 95 + "-dry" 96 + "-continue_on_error" 97 + ]; 98 + 99 + includes = [ 100 + "*.yml" 101 + "*.yaml" 102 + ]; 103 + }; 104 + }; 105 + }; 106 + }; 107 + }; 108 + }
modules/home/default.nix

This is a binary file and will not be displayed.

+3
modules/nixos/default.nix
··· 1 + { 2 + 3 + }
+1 -4
systems/apricot/default.nix
··· 1 - { 2 - 3 - }: 4 - { 1 + _: { 5 2 6 3 }
+4 -2
systems/pineapple/default.nix
··· 1 1 { 2 - 2 + ... 3 3 }: 4 4 { 5 - 5 + imports = [ 6 + ./fileSystem.nix 7 + ]; 6 8 }