diff --git a/checks/deploy/default.nix b/checks/deploy/default.nix deleted file mode 100644 index 84b64a8b4..000000000 --- a/checks/deploy/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ inputs, ... }: -builtins.mapAttrs (_: deployLib: deployLib.deployChecks inputs.self.deploy) inputs.deploy-rs.lib diff --git a/flake-modules/default.nix b/flake-modules/default.nix new file mode 100644 index 000000000..7e056c7cd --- /dev/null +++ b/flake-modules/default.nix @@ -0,0 +1,20 @@ +{ inputs, ... }: +{ + imports = [ + ./dev + ./lib.nix + ./packages.nix + ./templates.nix + ]; + + perSystem = + { system, ... }: + { + _module.args = { + pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + }; + }; +} diff --git a/flake-modules/dev/default.nix b/flake-modules/dev/default.nix new file mode 100644 index 000000000..d05d6f4ef --- /dev/null +++ b/flake-modules/dev/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ./devshell.nix + ./git-hooks.nix + ./treefmt.nix + ]; +} diff --git a/flake-modules/dev/devshell.nix b/flake-modules/dev/devshell.nix new file mode 100644 index 000000000..5cc675fc9 --- /dev/null +++ b/flake-modules/dev/devshell.nix @@ -0,0 +1,60 @@ +{ lib, inputs, ... }: +{ + imports = lib.optional (inputs.devshell ? flakeModule) inputs.devshell.flakeModule; + + perSystem = + { + lib, + pkgs, + config, + self', + system, + ... + }: + lib.optionalAttrs (inputs.devshell ? flakeModule) { + devshells.default = { + devshell.startup.pre-commit.text = config.pre-commit.installationScript; + + commands = [ + { + name = "checks"; + help = "Run all checks"; + command = '' + echo "=> Running all checks..." + + nix flake check "$@" + ''; + } + { + name = "format"; + help = "Format the entire codebase"; + command = "nix fmt"; + } + { + name = "docs"; + help = "Build khanelinix documentation"; + command = '' + echo "=> Building khanelinix documentation..." + + ${pkgs.lib.getExe pkgs.nix-output-monitor} build .#docs "$@" + ''; + } + { + name = "serve-docs"; + help = "Build and serve documentation locally"; + command = '' + echo -e "=> Building khanelinix documentation...\n" + + doc_derivation=$(${pkgs.lib.getExe pkgs.nix-output-monitor} build .#docs --no-link --print-out-paths) + + echo -e "\n=> Documentation successfully built ('$doc_derivation')" + + echo -e "\n=> You can then open your browser to view the doc\n" + + (cd "$doc_derivation"/share/doc && ${pkgs.lib.getExe pkgs.python3} ${./server.py}) + ''; + } + ]; + }; + }; +} diff --git a/flake-modules/dev/git-hooks.nix b/flake-modules/dev/git-hooks.nix new file mode 100644 index 000000000..47527d691 --- /dev/null +++ b/flake-modules/dev/git-hooks.nix @@ -0,0 +1,40 @@ +{ lib, inputs, ... }: +{ + imports = lib.optional (inputs.git-hooks-nix ? flakeModule) inputs.git-hooks-nix.flakeModule; + + perSystem = + { + lib, + pkgs, + ... + }: + lib.optionalAttrs (inputs.git-hooks-nix ? flakeModule) { + pre-commit = { + check.enable = false; + + settings.hooks = { + actionlint.enable = true; + clang-tidy.enable = true; + deadnix = { + enable = true; + + settings = { + edit = true; + }; + }; + eslint = { + enable = true; + package = pkgs.eslint_d; + }; + luacheck.enable = true; + pre-commit-hook-ensure-sops.enable = true; + statix.enable = true; + treefmt.enable = true; + typos = { + enable = true; + excludes = [ "generated/*" ]; + }; + }; + }; + }; +} diff --git a/flake-modules/dev/server.py b/flake-modules/dev/server.py new file mode 100644 index 000000000..5300c916c --- /dev/null +++ b/flake-modules/dev/server.py @@ -0,0 +1,16 @@ +import http.server + +PORT = 8000 + + +class UncachedHTTPHandler(http.server.SimpleHTTPRequestHandler): + def end_headers(self): + self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") + self.send_header("Pragma", "no-cache") + self.send_header("Expires", "0") + super().end_headers() + + +with http.server.HTTPServer(("", PORT), UncachedHTTPHandler) as httpd: + print(f"Serving documentation at http://localhost:{PORT}/nixvim") + httpd.serve_forever() diff --git a/flake-modules/dev/treefmt.nix b/flake-modules/dev/treefmt.nix new file mode 100644 index 000000000..512b3dc21 --- /dev/null +++ b/flake-modules/dev/treefmt.nix @@ -0,0 +1,109 @@ +{ lib, inputs, ... }: +{ + imports = lib.optional (inputs.treefmt-nix ? flakeModule) inputs.treefmt-nix.flakeModule; + + perSystem = + { + lib, + pkgs, + ... + }: + lib.optionalAttrs (inputs.treefmt-nix ? flakeModule) { + treefmt = { + projectRootFile = "flake.nix"; + + programs = { + actionlint.enable = true; + biome = { + enable = true; + settings.formatter.formatWithErrors = true; + }; + clang-format.enable = true; + deadnix = { + enable = true; + }; + deno = { + enable = true; + # Using biome for these + excludes = [ + "*.ts" + "*.js" + "*.json" + "*.jsonc" + ]; + }; + fantomas.enable = true; + fish_indent.enable = true; + gofmt.enable = true; + isort.enable = true; + nixfmt.enable = true; + nufmt.enable = true; + ruff-check.enable = true; + ruff-format.enable = true; + rustfmt.enable = true; + shfmt = { + enable = true; + indent_size = 4; + }; + statix.enable = true; + stylua.enable = true; + taplo.enable = true; + yamlfmt.enable = true; + }; + + settings = { + global.excludes = [ + "*.editorconfig" + "*.envrc" + "*.gitconfig" + "*.git-blame-ignore-revs" + "*.gitignore" + "*.gitattributes" + "*.luacheckrc" + "*CODEOWNERS" + "*LICENSE" + "*flake.lock" + "*.svg" + "*.png" + "*.gif" + "*.ico" + # TODO: formatters? + "*Makefile" + "*makefile" + "*.xml" + "*.zsh" + "*.rasi" + "*.kdl" + + # TODO: exceptions + # WARN no formatter for path: homes/x86_64-linux/nixos@CORE-PW00LM92/git/windows-compat-config + # WARN no formatter for path: modules/darwin/desktop/wms/yabai/extraConfig + # WARN no formatter for path: modules/home/programs/graphical/addons/electron-support/electron-flags.conf + # WARN no formatter for path: modules/home/programs/graphical/addons/kanshi/config + # WARN no formatter for path: modules/home/programs/graphical/addons/mako/config + # WARN no formatter for path: modules/home/programs/graphical/addons/swappy/config + # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/helper/islandhelper + # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/scripts/islands/music/cava.conf + # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/scripts/islands/music/get_artwork.scpt + # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/scripts/islands/volume/data/cache + # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/sketchybarrc + # WARN no formatter for path: modules/home/programs/graphical/launchers/wofi/config + # WARN no formatter for path: modules/home/programs/terminal/editors/micro/catppuccin-macchiato.micro + # WARN no formatter for path: modules/home/programs/terminal/tools/tmux/config/general.tmux + # WARN no formatter for path: modules/home/theme/qt/Kvantum/Catppuccin-Macchiato-Blue/Catppuccin-Macchiato-Blue.kvconfig + # WARN no formatter for path: modules/home/theme/qt/Kvantum/kvantum.kvconfig + # WARN no formatter for path: modules/nixos/programs/graphical/addons/looking-glass-client/client.ini + # WARN no formatter for path: systems/x86_64-linux/khanelinix/hyprlandOutput + # WARN no formatter for path: systems/x86_64-linux/khanelinix/swayOutput + # WARN no formatter for path: templates/c/Makefile.in + # WARN no formatter for path: templates/c/configure.ac + # WARN no formatter for path: templates/dotnetf/HelloWorld.Test/HelloWorld.Test.fsproj + # WARN no formatter for path: templates/dotnetf/HelloWorld.sln + # WARN no formatter for path: templates/dotnetf/HelloWorld/HelloWorld.fsproj + ]; + + formatter.ruff-format.options = [ "--isolated" ]; + }; + }; + }; +} diff --git a/flake-modules/lib.nix b/flake-modules/lib.nix new file mode 100644 index 000000000..44a637e2b --- /dev/null +++ b/flake-modules/lib.nix @@ -0,0 +1,19 @@ +{ + config, + lib, + withSystem, + ... +}: +{ + _module.args.helpers = import ../lib { inherit lib; }; + + flake.lib = lib.genAttrs config.systems ( + lib.flip withSystem ( + { pkgs, ... }: + { + check = import ../lib/tests.nix { inherit lib pkgs; }; + helpers = import ../lib { inherit lib pkgs; }; + } + ) + ); +} diff --git a/flake-modules/packages.nix b/flake-modules/packages.nix new file mode 100644 index 000000000..4e41bb01f --- /dev/null +++ b/flake-modules/packages.nix @@ -0,0 +1,23 @@ +{ inputs, ... }: +{ + perSystem = + { + config, + inputs', + system, + ... + }: + { + imports = [ + # ../packages/default.nix + ]; + + # packages = import ../docs { + # inherit system; + # inherit (inputs) nixpkgs; + # }; + + # Test that all packages build fine when running `nix flake check`. + checks = config.packages; + }; +} diff --git a/flake-modules/templates.nix b/flake-modules/templates.nix new file mode 100644 index 000000000..e109acf1b --- /dev/null +++ b/flake-modules/templates.nix @@ -0,0 +1,66 @@ +{ self, inputs, ... }: +let + templatesDir = ../templates; + templates = builtins.attrNames (builtins.readDir templatesDir); + generateTemplate = name: { + description = "${name} template"; + path = "${templatesDir}/${name}"; + }; +in +{ + flake.templates = builtins.listToAttrs ( + map (name: { + name = name; + value = generateTemplate name; + }) templates + ); + + # The following adds the template flake's checks to the main (current) flake's checks. + # It ensures that the template's own checks are successful. + perSystem = + { + pkgs, + system, + lib, + ... + }: + { + checks = + let + callFlake = + args@{ + inputs, + outputs, + sourceInfo, + }: + let + result = { + outputs = args.outputs (inputs // { self = result; }); + }; + in + result; + + templateFlakeOutputs = map ( + template: + callFlake { + inputs = { + inherit (inputs) flake-parts nixpkgs; + }; + # Import and read the `outputs` field of the template flake. + outputs = import (templatesDir + "/${template}/flake.nix"); + sourceInfo = { }; + } + ) templates; + + templateChecks = lib.concatMap ( + templateOutput: templateOutput.checks.${system} or [ ] + ) templateFlakeOutputs; + in + lib.listToAttrs ( + map (check: { + name = "template-${check.name}"; + value = check; + }) templateChecks + ); + }; +} diff --git a/flake.lock b/flake.lock index 50270385a..3cfc9677c 100644 --- a/flake.lock +++ b/flake.lock @@ -75,8 +75,8 @@ "blink-cmp": { "inputs": { "fenix": "fenix", - "flake-parts": "flake-parts_3", - "nixpkgs": "nixpkgs_12" + "flake-parts": "flake-parts_4", + "nixpkgs": "nixpkgs_13" }, "locked": { "lastModified": 1735935822, @@ -257,6 +257,24 @@ } }, "devshell": { + "inputs": { + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1735644329, + "narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=", + "owner": "numtide", + "repo": "devshell", + "rev": "f7795ede5b02664b57035b3b757876703e2c3eac", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "devshell_2": { "inputs": { "nixpkgs": [ "khanelivim", @@ -280,7 +298,7 @@ }, "disko": { "inputs": { - "nixpkgs": "nixpkgs_6" + "nixpkgs": "nixpkgs_7" }, "locked": { "lastModified": 1734088167, @@ -522,6 +540,24 @@ "inputs": { "nixpkgs-lib": "nixpkgs-lib_2" }, + "locked": { + "lastModified": 1735774679, + "narHash": "sha256-soePLBazJk0qQdDVhdbM98vYdssfs3WFedcq+raipRI=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f2f7418ce0ab4a5309a4596161d154cfc877af66", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, "locked": { "lastModified": 1733312601, "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", @@ -536,7 +572,7 @@ "type": "github" } }, - "flake-parts_4": { + "flake-parts_5": { "inputs": { "nixpkgs-lib": [ "khanelivim", @@ -558,7 +594,7 @@ "type": "github" } }, - "flake-parts_5": { + "flake-parts_6": { "inputs": { "nixpkgs-lib": [ "lanzaboote", @@ -579,7 +615,7 @@ "type": "github" } }, - "flake-parts_6": { + "flake-parts_7": { "inputs": { "nixpkgs-lib": [ "nur", @@ -828,7 +864,7 @@ "inputs": { "flake-compat": "flake-compat_2", "gitignore": "gitignore", - "nixpkgs": "nixpkgs_7" + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1735882644, @@ -994,7 +1030,7 @@ }, "home-manager_2": { "inputs": { - "nixpkgs": "nixpkgs_8" + "nixpkgs": "nixpkgs_9" }, "locked": { "lastModified": 1735925111, @@ -1034,7 +1070,7 @@ }, "hypr-socket-watch": { "inputs": { - "nixpkgs": "nixpkgs_9", + "nixpkgs": "nixpkgs_10", "rust-overlay": "rust-overlay" }, "locked": { @@ -1119,7 +1155,7 @@ "hyprlang": "hyprlang", "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", - "nixpkgs": "nixpkgs_11", + "nixpkgs": "nixpkgs_12", "pre-commit-hooks": "pre-commit-hooks", "systems": "systems_5", "xdph": "xdph" @@ -1339,7 +1375,7 @@ "git-hooks-nix": [ "git-hooks-nix" ], - "nixpkgs": "nixpkgs_13", + "nixpkgs": "nixpkgs_14", "nixpkgs-tree-sitter": "nixpkgs-tree-sitter", "nixvim": "nixvim", "snowfall-flake": [ @@ -1367,9 +1403,9 @@ "inputs": { "crane": "crane", "flake-compat": "flake-compat_5", - "flake-parts": "flake-parts_5", + "flake-parts": "flake-parts_6", "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_15", + "nixpkgs": "nixpkgs_16", "pre-commit-hooks-nix": "pre-commit-hooks-nix", "rust-overlay": "rust-overlay_2" }, @@ -1444,7 +1480,7 @@ }, "nix-index-database": { "inputs": { - "nixpkgs": "nixpkgs_16" + "nixpkgs": "nixpkgs_17" }, "locked": { "lastModified": 1735443188, @@ -1517,6 +1553,18 @@ } }, "nixpkgs-lib_2": { + "locked": { + "lastModified": 1735774519, + "narHash": "sha256-CewEm1o2eVAnoqb6Ml+Qi9Gg/EfNAxbRx1lANGVyoLI=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" + } + }, + "nixpkgs-lib_3": { "locked": { "lastModified": 1733096140, "narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=", @@ -1624,6 +1672,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1714253743, + "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1706487304, "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", @@ -1639,7 +1703,7 @@ "type": "github" } }, - "nixpkgs_11": { + "nixpkgs_12": { "locked": { "lastModified": 1735291276, "narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=", @@ -1655,7 +1719,7 @@ "type": "github" } }, - "nixpkgs_12": { + "nixpkgs_13": { "locked": { "lastModified": 1734435836, "narHash": "sha256-kMBQ5PRiFLagltK0sH+08aiNt3zGERC2297iB6vrvlU=", @@ -1671,7 +1735,7 @@ "type": "github" } }, - "nixpkgs_13": { + "nixpkgs_14": { "locked": { "lastModified": 1735821806, "narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=", @@ -1687,7 +1751,7 @@ "type": "github" } }, - "nixpkgs_14": { + "nixpkgs_15": { "locked": { "lastModified": 1735834308, "narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=", @@ -1703,7 +1767,7 @@ "type": "github" } }, - "nixpkgs_15": { + "nixpkgs_16": { "locked": { "lastModified": 1717794163, "narHash": "sha256-Ch6ZpFPVvi7Bb6gmmuufpTEFkXqa43pC94XMfU5FEt0=", @@ -1719,7 +1783,7 @@ "type": "github" } }, - "nixpkgs_16": { + "nixpkgs_17": { "locked": { "lastModified": 1735291276, "narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=", @@ -1735,7 +1799,7 @@ "type": "github" } }, - "nixpkgs_17": { + "nixpkgs_18": { "locked": { "lastModified": 1735834308, "narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=", @@ -1751,7 +1815,7 @@ "type": "github" } }, - "nixpkgs_18": { + "nixpkgs_19": { "locked": { "lastModified": 1735834308, "narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=", @@ -1767,7 +1831,20 @@ "type": "github" } }, - "nixpkgs_19": { + "nixpkgs_2": { + "locked": { + "lastModified": 1690031011, + "narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", + "path": "/nix/store/gxw5rlp29swdpgz26vhaqzy21b9pxrim-source", + "rev": "12303c652b881435065a98729eb7278313041e49", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_20": { "locked": { "lastModified": 1704290814, "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", @@ -1783,20 +1860,7 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1690031011, - "narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", - "path": "/nix/store/gxw5rlp29swdpgz26vhaqzy21b9pxrim-source", - "rev": "12303c652b881435065a98729eb7278313041e49", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_20": { + "nixpkgs_21": { "locked": { "lastModified": 1731763621, "narHash": "sha256-ddcX4lQL0X05AYkrkV2LMFgGdRvgap7Ho8kgon3iWZk=", @@ -1812,7 +1876,7 @@ "type": "github" } }, - "nixpkgs_21": { + "nixpkgs_22": { "locked": { "lastModified": 1735554305, "narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=", @@ -1828,7 +1892,7 @@ "type": "github" } }, - "nixpkgs_22": { + "nixpkgs_23": { "locked": { "lastModified": 1735471104, "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", @@ -1844,7 +1908,7 @@ "type": "github" } }, - "nixpkgs_23": { + "nixpkgs_24": { "locked": { "lastModified": 1735821806, "narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=", @@ -1909,11 +1973,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1733749988, - "narHash": "sha256-+5qdtgXceqhK5ZR1YbP1fAUsweBIrhL38726oIEAtDs=", + "lastModified": 1722073938, + "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "bc27f0fde01ce4e1bfec1ab122d72b7380278e68", + "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", "type": "github" }, "original": { @@ -1925,11 +1989,11 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1730768919, - "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", + "lastModified": 1733749988, + "narHash": "sha256-+5qdtgXceqhK5ZR1YbP1fAUsweBIrhL38726oIEAtDs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", + "rev": "bc27f0fde01ce4e1bfec1ab122d72b7380278e68", "type": "github" }, "original": { @@ -1941,27 +2005,27 @@ }, "nixpkgs_8": { "locked": { - "lastModified": 1735471104, - "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", + "lastModified": 1730768919, + "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4", + "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_9": { "locked": { - "lastModified": 1714253743, - "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "lastModified": 1735471104, + "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4", "type": "github" }, "original": { @@ -1973,13 +2037,13 @@ }, "nixvim": { "inputs": { - "devshell": "devshell", + "devshell": "devshell_2", "flake-compat": "flake-compat_4", - "flake-parts": "flake-parts_4", + "flake-parts": "flake-parts_5", "git-hooks": "git-hooks", "home-manager": "home-manager_3", "nix-darwin": "nix-darwin", - "nixpkgs": "nixpkgs_14", + "nixpkgs": "nixpkgs_15", "nuschtosSearch": "nuschtosSearch", "treefmt-nix": "treefmt-nix" }, @@ -1999,8 +2063,8 @@ }, "nur": { "inputs": { - "flake-parts": "flake-parts_6", - "nixpkgs": "nixpkgs_18", + "flake-parts": "flake-parts_7", + "nixpkgs": "nixpkgs_19", "treefmt-nix": "treefmt-nix_2" }, "locked": { @@ -2123,7 +2187,9 @@ "catppuccin-cursors": "catppuccin-cursors", "darwin": "darwin", "deploy-rs": "deploy-rs", + "devshell": "devshell", "disko": "disko", + "flake-parts": "flake-parts_3", "git-hooks-nix": "git-hooks-nix", "home-manager": "home-manager_2", "hypr-socket-watch": "hypr-socket-watch", @@ -2133,7 +2199,7 @@ "nix-flatpak": "nix-flatpak", "nix-index-database": "nix-index-database", "nixos-wsl": "nixos-wsl", - "nixpkgs": "nixpkgs_17", + "nixpkgs": "nixpkgs_18", "nixpkgs-master": "nixpkgs-master", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur", @@ -2166,7 +2232,7 @@ "rust-overlay": { "inputs": { "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_10" + "nixpkgs": "nixpkgs_11" }, "locked": { "lastModified": 1714529851, @@ -2231,7 +2297,7 @@ "snowfall-flake": { "inputs": { "flake-compat": "flake-compat_7", - "nixpkgs": "nixpkgs_19", + "nixpkgs": "nixpkgs_20", "snowfall-lib": "snowfall-lib" }, "locked": { @@ -2296,7 +2362,7 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_20" + "nixpkgs": "nixpkgs_21" }, "locked": { "lastModified": 1735844895, @@ -2507,7 +2573,7 @@ }, "treefmt-nix_3": { "inputs": { - "nixpkgs": "nixpkgs_21" + "nixpkgs": "nixpkgs_22" }, "locked": { "lastModified": 1735905407, @@ -2544,7 +2610,7 @@ "waybar": { "inputs": { "flake-compat": "flake-compat_10", - "nixpkgs": "nixpkgs_22" + "nixpkgs": "nixpkgs_23" }, "locked": { "lastModified": 1735737557, @@ -2566,7 +2632,7 @@ "freetype2": "freetype2", "harfbuzz": "harfbuzz", "libpng": "libpng", - "nixpkgs": "nixpkgs_23", + "nixpkgs": "nixpkgs_24", "rust-overlay": "rust-overlay_3", "zlib": "zlib" }, diff --git a/flake.nix b/flake.nix index 6113e387a..5fde8432f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,50 @@ { description = "KhaneliNix"; - inputs = { + outputs = + inputs@{ flake-parts, self, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ./flake-modules + # inputs.flake-parts.flakeModules.flakeModules + # inputs.flake-parts.flakeModules.modules + ]; + + systems = [ + "x86_64-linux" + "aarch64-darwin" + ]; + flake = { + # channels-config = { + # allowUnfree = true; + # permittedInsecurePackages = [ + # "freeimage-unstable-2021-11-01" + # ]; + # }; + # + modules = { + darwin = with inputs; [ sops-nix.darwinModules.sops ]; + homes = with inputs; [ + anyrun.homeManagerModules.default + catppuccin.homeManagerModules.catppuccin + hypr-socket-watch.homeManagerModules.default + nix-index-database.hmModules.nix-index + nur.hmModules.nur + sops-nix.homeManagerModules.sops + ]; + nixos = with inputs; [ + lanzaboote.nixosModules.lanzaboote + sops-nix.nixosModules.sops + ]; + }; + deploy = { + inherit self; + }; + }; + }; + + inputs = { # ╭──────────────────────────────────────────────────────────╮ # │ Core System │ # ╰──────────────────────────────────────────────────────────╯ @@ -14,16 +56,15 @@ inputs.nixpkgs.follows = "nixpkgs-unstable"; }; + devshell.url = "github:numtide/devshell"; + flake-parts.url = "github:hercules-ci/flake-parts"; git-hooks-nix.url = "github:cachix/git-hooks.nix"; - home-manager.url = "github:nix-community/home-manager"; # home-manager.url = "github:khaneliman/home-manager/thunderbird"; # home-manager.url = "git+file:///home/khaneliman/Documents/github/home-manager"; # home-manager.url = "git+file:///Users/khaneliman/Documents/github/home-manager"; - # Secure boot - lanzaboote.url = "github:nix-community/lanzaboote/v0.4.1"; - + lanzaboote.url = "github:nix-community/lanzaboote/v0.4.1"; # Secure boot nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; # FIXME: remove after upstream PRs are available @@ -39,11 +80,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - # Secrets management - sops-nix = { - url = "github:Mic92/sops-nix"; - }; - + sops-nix.url = "github:Mic92/sops-nix"; # Secrets management treefmt-nix.url = "github:numtide/treefmt-nix"; # ╭──────────────────────────────────────────────────────────╮ @@ -89,99 +126,99 @@ }; }; - outputs = - inputs: - let - inherit (inputs) snowfall-lib; - - lib = snowfall-lib.mkLib { - inherit inputs; - src = ./.; - - snowfall = { - meta = { - name = "khanelinix"; - title = "KhaneliNix"; - }; - - namespace = "khanelinix"; - }; - }; - in - lib.mkFlake { - channels-config = { - # allowBroken = true; - allowUnfree = true; - # showDerivationWarnings = [ "maintainerless" ]; - - # TODO: cleanup when available - permittedInsecurePackages = [ - # NOTE: needed by emulationstation - "freeimage-unstable-2021-11-01" - # dev shells - "aspnetcore-runtime-6.0.36" - "aspnetcore-runtime-7.0.20" - "aspnetcore-runtime-wrapped-7.0.20" - "aspnetcore-runtime-wrapped-6.0.36" - "dotnet-combined" - "dotnet-core-combined" - "dotnet-runtime-6.0.36" - "dotnet-runtime-7.0.20" - "dotnet-runtime-wrapped-6.0.36" - "dotnet-runtime-wrapped-7.0.20" - "dotnet-sdk-6.0.428" - "dotnet-sdk-7.0.410" - "dotnet-sdk-wrapped-6.0.428" - "dotnet-sdk-wrapped-7.0.410" - "dotnet-wrapped-combined" - ]; - }; - - overlays = [ ]; - - homes.modules = with inputs; [ - anyrun.homeManagerModules.default - catppuccin.homeManagerModules.catppuccin - hypr-socket-watch.homeManagerModules.default - nix-index-database.hmModules.nix-index - # FIXME: - # nur.modules.homeManager.default - sops-nix.homeManagerModules.sops - ]; - - systems = { - modules = { - darwin = with inputs; [ - sops-nix.darwinModules.sops - ]; - nixos = with inputs; [ - disko.nixosModules.disko - lanzaboote.nixosModules.lanzaboote - nix-flatpak.nixosModules.nix-flatpak - sops-nix.nixosModules.sops - ]; - }; - }; - - templates = { - angular.description = "Angular template"; - c.description = "C flake template."; - container.description = "Container template"; - cpp.description = "CPP flake template"; - dotnetf.description = "Dotnet FSharp template"; - flake-compat.description = "Flake-compat shell and default files."; - go.description = "Go template"; - node.description = "Node template"; - python.description = "Python template"; - rust.description = "Rust template"; - rust-web-server.description = "Rust web server template"; - snowfall.description = "Snowfall-lib template"; - }; - - deploy = lib.mkDeploy { inherit (inputs) self; }; - - outputs-builder = channels: { - formatter = inputs.treefmt-nix.lib.mkWrapper channels.nixpkgs ./treefmt.nix; - }; - }; + # outputs = + # inputs: + # let + # inherit (inputs) snowfall-lib; + # + # lib = snowfall-lib.mkLib { + # inherit inputs; + # src = ./.; + # + # snowfall = { + # meta = { + # name = "khanelinix"; + # title = "KhaneliNix"; + # }; + # + # namespace = "khanelinix"; + # }; + # }; + # in + # lib.mkFlake { + # channels-config = { + # # allowBroken = true; + # allowUnfree = true; + # # showDerivationWarnings = [ "maintainerless" ]; + # + # # TODO: cleanup when available + # permittedInsecurePackages = [ + # # NOTE: needed by emulationstation + # "freeimage-unstable-2021-11-01" + # # dev shells + # "aspnetcore-runtime-6.0.36" + # "aspnetcore-runtime-7.0.20" + # "aspnetcore-runtime-wrapped-7.0.20" + # "aspnetcore-runtime-wrapped-6.0.36" + # "dotnet-combined" + # "dotnet-core-combined" + # "dotnet-runtime-6.0.36" + # "dotnet-runtime-7.0.20" + # "dotnet-runtime-wrapped-6.0.36" + # "dotnet-runtime-wrapped-7.0.20" + # "dotnet-sdk-6.0.428" + # "dotnet-sdk-7.0.410" + # "dotnet-sdk-wrapped-6.0.428" + # "dotnet-sdk-wrapped-7.0.410" + # "dotnet-wrapped-combined" + # ]; + # }; + # + # overlays = [ ]; + # + # homes.modules = with inputs; [ + # anyrun.homeManagerModules.default + # catppuccin.homeManagerModules.catppuccin + # hypr-socket-watch.homeManagerModules.default + # nix-index-database.hmModules.nix-index + # # FIXME: + # # nur.modules.homeManager.default + # sops-nix.homeManagerModules.sops + # ]; + # + # systems = { + # modules = { + # darwin = with inputs; [ + # sops-nix.darwinModules.sops + # ]; + # nixos = with inputs; [ + # disko.nixosModules.disko + # lanzaboote.nixosModules.lanzaboote + # nix-flatpak.nixosModules.nix-flatpak + # sops-nix.nixosModules.sops + # ]; + # }; + # }; + # + # templates = { + # angular.description = "Angular template"; + # c.description = "C flake template."; + # container.description = "Container template"; + # cpp.description = "CPP flake template"; + # dotnetf.description = "Dotnet FSharp template"; + # flake-compat.description = "Flake-compat shell and default files."; + # go.description = "Go template"; + # node.description = "Node template"; + # python.description = "Python template"; + # rust.description = "Rust template"; + # rust-web-server.description = "Rust web server template"; + # snowfall.description = "Snowfall-lib template"; + # }; + # + # deploy = lib.mkDeploy { inherit (inputs) self; }; + # + # outputs-builder = channels: { + # formatter = inputs.treefmt-nix.lib.mkWrapper channels.nixpkgs ./treefmt.nix; + # }; + # }; } diff --git a/templates/angular/flake.nix b/templates/angular/flake.nix index c152f6a1d..5af48c50d 100644 --- a/templates/angular/flake.nix +++ b/templates/angular/flake.nix @@ -5,7 +5,7 @@ }; outputs = - { nixpkgs }: + { self, nixpkgs }: let systems = [ "x86_64-linux" @@ -25,5 +25,11 @@ }); hydraJobs = packages; + + checks = forEachSystem (system: { + default = pkgsForEach.${system}.runCommand "check" { } '' + echo "Running checks for ${system}" + ''; + }); }; } diff --git a/templates/cpp/flake.nix b/templates/cpp/flake.nix index 88544b8ad..3ef888075 100644 --- a/templates/cpp/flake.nix +++ b/templates/cpp/flake.nix @@ -5,7 +5,7 @@ }; outputs = - { nixpkgs, ... }: + { self, nixpkgs, ... }: let systems = [ "x86_64-linux" diff --git a/templates/dotnetf/flake.nix b/templates/dotnetf/flake.nix index 2a64433cf..e5392805b 100644 --- a/templates/dotnetf/flake.nix +++ b/templates/dotnetf/flake.nix @@ -5,7 +5,12 @@ flake-utils.url = "github:numtide/flake-utils"; }; outputs = - { nixpkgs, flake-utils, ... }: + { + self, + nixpkgs, + flake-utils, + ... + }: flake-utils.lib.eachDefaultSystem ( system: let diff --git a/templates/go/flake.nix b/templates/go/flake.nix index d08f4673c..215673549 100644 --- a/templates/go/flake.nix +++ b/templates/go/flake.nix @@ -5,7 +5,7 @@ }; outputs = - { nixpkgs }: + { self, nixpkgs }: let systems = [ "x86_64-linux" diff --git a/templates/node/flake.nix b/templates/node/flake.nix index c811bf749..30eb2a3bf 100644 --- a/templates/node/flake.nix +++ b/templates/node/flake.nix @@ -5,7 +5,7 @@ }; outputs = - { nixpkgs }: + { self, nixpkgs }: let systems = [ "x86_64-linux" diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 3a0b9a99d..b3f1a093f 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -5,7 +5,7 @@ }; outputs = - { nixpkgs }: + { self, nixpkgs }: let systems = [ "x86_64-linux" diff --git a/treefmt.nix b/treefmt.nix deleted file mode 100644 index e6911b253..000000000 --- a/treefmt.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - projectRootFile = "flake.nix"; - - programs = { - actionlint.enable = true; - biome = { - enable = true; - settings.formatter.formatWithErrors = true; - }; - clang-format.enable = true; - deadnix = { - enable = true; - }; - deno = { - enable = true; - # Using biome for these - excludes = [ - "*.ts" - "*.js" - "*.json" - "*.jsonc" - ]; - }; - fantomas.enable = true; - fish_indent.enable = true; - gofmt.enable = true; - isort.enable = true; - nixfmt.enable = true; - nufmt.enable = true; - ruff-check.enable = true; - ruff-format.enable = true; - rustfmt.enable = true; - shfmt = { - enable = true; - indent_size = 4; - }; - statix.enable = true; - stylua.enable = true; - taplo.enable = true; - yamlfmt.enable = true; - }; - - settings = { - global.excludes = [ - "*.editorconfig" - "*.envrc" - "*.gitconfig" - "*.git-blame-ignore-revs" - "*.gitignore" - "*.gitattributes" - "*.luacheckrc" - "*CODEOWNERS" - "*LICENSE" - "*flake.lock" - "*.svg" - "*.png" - "*.gif" - "*.ico" - # TODO: formatters? - "*Makefile" - "*makefile" - "*.xml" - "*.zsh" - "*.rasi" - "*.kdl" - - # TODO: exceptions - # WARN no formatter for path: homes/x86_64-linux/nixos@CORE-PW00LM92/git/windows-compat-config - # WARN no formatter for path: modules/darwin/desktop/wms/yabai/extraConfig - # WARN no formatter for path: modules/home/programs/graphical/addons/electron-support/electron-flags.conf - # WARN no formatter for path: modules/home/programs/graphical/addons/kanshi/config - # WARN no formatter for path: modules/home/programs/graphical/addons/mako/config - # WARN no formatter for path: modules/home/programs/graphical/addons/swappy/config - # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/helper/islandhelper - # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/scripts/islands/music/cava.conf - # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/scripts/islands/music/get_artwork.scpt - # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/scripts/islands/volume/data/cache - # WARN no formatter for path: modules/home/programs/graphical/bars/sketchybar/dynamic-island-sketchybar/sketchybarrc - # WARN no formatter for path: modules/home/programs/graphical/launchers/wofi/config - # WARN no formatter for path: modules/home/programs/terminal/editors/micro/catppuccin-macchiato.micro - # WARN no formatter for path: modules/home/programs/terminal/tools/tmux/config/general.tmux - # WARN no formatter for path: modules/home/theme/qt/Kvantum/Catppuccin-Macchiato-Blue/Catppuccin-Macchiato-Blue.kvconfig - # WARN no formatter for path: modules/home/theme/qt/Kvantum/kvantum.kvconfig - # WARN no formatter for path: modules/nixos/programs/graphical/addons/looking-glass-client/client.ini - # WARN no formatter for path: systems/x86_64-linux/khanelinix/hyprlandOutput - # WARN no formatter for path: systems/x86_64-linux/khanelinix/swayOutput - # WARN no formatter for path: templates/c/Makefile.in - # WARN no formatter for path: templates/c/configure.ac - # WARN no formatter for path: templates/dotnetf/HelloWorld.Test/HelloWorld.Test.fsproj - # WARN no formatter for path: templates/dotnetf/HelloWorld.sln - # WARN no formatter for path: templates/dotnetf/HelloWorld/HelloWorld.fsproj - ]; - - formatter.ruff-format.options = [ "--isolated" ]; - }; -}