From 3bc7761c1cbda105bd62bd91d27b1406dcc843a9 Mon Sep 17 00:00:00 2001 From: poz Date: Thu, 14 May 2026 19:38:25 +0200 Subject: [PATCH] flake: remove `flake-parts` and `nix-systems` from flake --- docs/manual/release-notes/rl-0.9.md | 1 + flake.lock | 47 +----- flake.nix | 235 +++++++++++++++++----------- flake/apps.nix | 11 -- flake/develop.nix | 42 ----- flake/packages.nix | 219 +++++++++++++------------- flake/templates/default.nix | 22 ++- 7 files changed, 267 insertions(+), 310 deletions(-) delete mode 100644 flake/apps.nix delete mode 100644 flake/develop.nix diff --git a/docs/manual/release-notes/rl-0.9.md b/docs/manual/release-notes/rl-0.9.md index a1c95e9f..5a2281ba 100644 --- a/docs/manual/release-notes/rl-0.9.md +++ b/docs/manual/release-notes/rl-0.9.md @@ -500,6 +500,7 @@ https://github.com/gorbit99/codewindow.nvim [fish_indent]. Most of the work done by [poseidon-rises](https://github.com/poseidon-rises) in [!1107](https://github.com/NotAShelf/nvf/pull/1107). +- Remove `flake-parts` and `nix-systems` from flake. [emo-mruczek](https://emo-mruczek.pet): diff --git a/flake.lock b/flake.lock index 2668ceb2..8ff6225b 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1751685974, - "narHash": "sha256-NKw96t+BgHIYzHUjkTK95FqYRVKB8DHpVhefWSz/kTw=", + "lastModified": 1777699697, + "narHash": "sha256-Eg9b/rq/ECYwNwEXs5i9wHyhxNI0JrYx2srdI2uZMaQ=", "ref": "refs/heads/main", - "rev": "549f2762aebeff29a2e5ece7a7dc0f955281a1d1", - "revCount": 92, + "rev": "382052b74656a369c5408822af3f2501e9b1af81", + "revCount": 94, "type": "git", "url": "https://git.lix.systems/lix-project/flake-compat.git" }, @@ -16,26 +16,6 @@ "url": "https://git.lix.systems/lix-project/flake-compat.git" } }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1769996383, - "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "mnw": { "locked": { "lastModified": 1777828893, @@ -91,26 +71,9 @@ "root": { "inputs": { "flake-compat": "flake-compat", - "flake-parts": "flake-parts", "mnw": "mnw", "ndg": "ndg", - "nixpkgs": "nixpkgs", - "systems": "systems" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index ba817494..a06bb04d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,71 +1,67 @@ { description = "A neovim flake with a modular configuration"; outputs = { - flake-parts, self, + nixpkgs, ... } @ inputs: let + systems = nixpkgs.lib.platforms.all; + + # Provide simple per-system abstraction + # either giving you the system directly + # or the package set for that system. + eachSystem = nixpkgs.lib.genAttrs systems; + + eachSystemPkgs = f: + nixpkgs.lib.genAttrs systems + (system: f nixpkgs.legacyPackages.${system}); + # Call the extended library with `inputs`. # inputs is used to get the original standard library, and to pass inputs # to the plugin autodiscovery function lib = import ./lib/stdlib-extended.nix {inherit inputs self;}; - in - flake-parts.lib.mkFlake { - inherit inputs; - specialArgs = {inherit lib;}; - } { - # Allow users to bring their own systems. - # «https://github.com/nix-systems/nix-systems» - systems = import inputs.systems; - imports = [ - ./flake/templates - ./flake/apps.nix - ./flake/packages.nix - ./flake/develop.nix - ]; + in { + lib = { + inherit (lib) nvim; + inherit (lib.nvim) neovimConfiguration; + }; - flake = { - lib = { - inherit (lib) nvim; - inherit (lib.nvim) neovimConfiguration; - }; + inherit (lib.importJSON ./npins/sources.json) pins; - inherit (lib.importJSON ./npins/sources.json) pins; + homeManagerModules = { + nvf = import ./flake/modules/home-manager.nix {inherit lib inputs;}; + default = self.homeManagerModules.nvf; + neovim-flake = + lib.warn '' + 'homeManagerModules.neovim-flake' has been deprecated, and will be removed + in a future release. Please use 'homeManagerModules.nvf' instead. + '' + self.homeManagerModules.nvf; + }; - homeManagerModules = { - nvf = import ./flake/modules/home-manager.nix {inherit lib inputs;}; - default = self.homeManagerModules.nvf; - neovim-flake = - lib.warn '' - 'homeManagerModules.neovim-flake' has been deprecated, and will be removed - in a future release. Please use 'homeManagerModules.nvf' instead. - '' - self.homeManagerModules.nvf; - }; + nixosModules = { + nvf = import ./flake/modules/nixos.nix {inherit lib inputs;}; + default = self.nixosModules.nvf; + neovim-flake = + lib.warn '' + 'nixosModules.neovim-flake' has been deprecated, and will be removed + in a future release. Please use 'nixosModules.nvf' instead. + '' + self.nixosModules.nvf; + }; - nixosModules = { - nvf = import ./flake/modules/nixos.nix {inherit lib inputs;}; - default = self.nixosModules.nvf; - neovim-flake = - lib.warn '' - 'nixosModules.neovim-flake' has been deprecated, and will be removed - in a future release. Please use 'nixosModules.nvf' instead. - '' - self.nixosModules.nvf; - }; + darwinModules = { + nvf = import ./flake/modules/nixos.nix {inherit lib inputs;}; + default = self.darwinModules.nvf; + }; - darwinModules = { - nvf = import ./flake/modules/nixos.nix {inherit lib inputs;}; - default = self.darwinModules.nvf; - }; - }; - - perSystem = {pkgs, ...}: { - # Provides the default formatter for 'nix fmt', which will format the - # entire Nix source with Alejandra. The wrapper script is necessary due to - # changes to the behaviour of Nix, which now encourages wrappers for - # tree-wide formatting. - formatter = pkgs.writeShellApplication { + # Provides the default formatter for 'nix fmt', which will format the + # entire Nix source with Alejandra. The wrapper script is necessary due to + # changes to the behaviour of Nix, which now encourages wrappers for + # tree-wide formatting. + formatter = eachSystemPkgs ( + pkgs: + pkgs.writeShellApplication { name = "nix3-fmt-wrapper"; runtimeInputs = [ @@ -83,52 +79,109 @@ echo "Formatting Markdown files" fd "$@" -t f -e md -x deno fmt -q '{}' ''; - }; + } + ); - # Provides checks to be built an ran on 'nix flake check'. They can also - # be built individually with 'nix build' as described below. - checks = { - # Check if codebase is properly formatted. - # This can be initiated with `nix build .#checks..nix-fmt` - # or with `nix flake check` - nix-fmt = - pkgs.runCommand "nix-fmt-check" - { - src = self; - nativeBuildInputs = [pkgs.alejandra pkgs.fd]; - } '' - cd "$src" - fd -t f -e nix -x alejandra --check '{}' - touch $out - ''; + # Provides checks to be built an ran on 'nix flake check'. They can also + # be built individually with 'nix build' as described below. + checks = eachSystemPkgs (pkgs: { + # Check if codebase is properly formatted. + # This can be initiated with `nix build .#checks..nix-fmt` + # or with `nix flake check` + nix-fmt = + pkgs.runCommand "nix-fmt-check" + { + src = self; + nativeBuildInputs = [pkgs.alejandra pkgs.fd]; + } '' + cd "$src" + fd -t f -e nix -x alejandra --check '{}' + touch $out + ''; - # Check if Markdown sources are properly formatted - # This can be initiated with `nix build .#checks..md-fmt` - # or with `nix flake check` - md-fmt = - pkgs.runCommand "md-fmt-check" { - src = self; - nativeBuildInputs = [pkgs.deno pkgs.fd]; - } '' - cd "$src" - fd -t f -e md -x deno fmt --check '{}' - touch $out - ''; - }; + # Check if Markdown sources are properly formatted + # This can be initiated with `nix build .#checks..md-fmt` + # or with `nix flake check` + md-fmt = + pkgs.runCommand "md-fmt-check" { + src = self; + nativeBuildInputs = [pkgs.deno pkgs.fd]; + } '' + cd "$src" + fd -t f -e md -x deno fmt --check '{}' + touch $out + ''; + }); + + templates = import ./flake/templates; + + apps = eachSystem (system: let + inherit (lib.meta) getExe; + in { + nix = { + type = "app"; + program = getExe self.packages.${system}.nix; + meta = {}; }; - }; + maximal = { + type = "app"; + program = getExe self.packages.${system}.maximal; + meta = {}; + }; + default = self.apps.${system}.nix; + }); + + packages = let + inherit (lib.attrsets) recursiveUpdate; + in + recursiveUpdate + (eachSystem (system: import ./flake/packages.nix {inherit inputs lib self system;})) + (eachSystemPkgs (pkgs: { + # This package exists to make development easier by providing the place and + # boilerplate to build a test nvf configuration. Feel free to use this for + # testing, but make sure to discard the changes before creating a pull + # request. + dev = let + configuration = { + # This is essentially the configuration that will be passed to the + # builder function. For example: + # vim.languages.nix.enable = true; + }; + + customNeovim = lib.nvim.neovimConfiguration { + inherit pkgs; + modules = [configuration]; + }; + in + customNeovim.neovim; + })); + + devShells = eachSystemPkgs (pkgs: { + # The default dev shell provides packages required to interact with + # the codebase as described by the contributing guidelines. It includes the + # formatters required, and a few additional goodies for linting work. + default = pkgs.mkShellNoCC { + packages = with pkgs; [ + # Nix tooling + nil # LSP + statix # static checker + deadnix # dead code finder + + # So that we can interact with plugin sources + npins + + # Formatters + alejandra + deno + ]; + }; + }); + }; inputs = { - systems.url = "github:nix-systems/default"; - ## Basic Inputs nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - flake-compat = { url = "git+https://git.lix.systems/lix-project/flake-compat.git"; flake = false; diff --git a/flake/apps.nix b/flake/apps.nix deleted file mode 100644 index 583e297e..00000000 --- a/flake/apps.nix +++ /dev/null @@ -1,11 +0,0 @@ -{lib, ...}: let - inherit (lib.meta) getExe; -in { - perSystem = {config, ...}: { - apps = { - nix.program = getExe config.packages.nix; - maximal.program = getExe config.packages.maximal; - default = config.apps.nix; - }; - }; -} diff --git a/flake/develop.nix b/flake/develop.nix deleted file mode 100644 index c05b2a9a..00000000 --- a/flake/develop.nix +++ /dev/null @@ -1,42 +0,0 @@ -{lib, ...}: { - perSystem = {pkgs, ...}: { - # The default dev shell provides packages required to interact with - # the codebase as described by the contributing guidelines. It includes the - # formatters required, and a few additional goodies for linting work. - devShells = { - default = pkgs.mkShellNoCC { - packages = with pkgs; [ - # Nix tooling - nil # LSP - statix # static checker - deadnix # dead code finder - - # So that we can interact with plugin sources - npins - - # Formatters - alejandra - deno - ]; - }; - }; - - # This package exists to make development easier by providing the place and - # boilerplate to build a test nvf configuration. Feel free to use this for - # testing, but make sure to discard the changes before creating a pull - # request. - packages.dev = let - configuration = { - # This is essentially the configuration that will be passed to the - # builder function. For example: - # vim.languages.nix.enable = true; - }; - - customNeovim = lib.nvim.neovimConfiguration { - inherit pkgs; - modules = [configuration]; - }; - in - customNeovim.neovim; - }; -} diff --git a/flake/packages.nix b/flake/packages.nix index 5927a3e4..15aa910b 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -1,127 +1,122 @@ { inputs, + lib, self, + system, ... -} @ args: { - perSystem = { - config, - pkgs, - lib, - ... - }: let - inherit (lib.customisation) makeScope; - inherit (lib.attrsets) isDerivation isAttrs concatMapAttrs; - inherit (lib.strings) concatStringsSep; - inherit (lib.filesystem) packagesFromDirectoryRecursive; +}: let + pkgs = inputs.nixpkgs.legacyPackages.${system}; - # Entrypoint for nvf documentation and relevant packages. - docs = import ../docs {inherit pkgs inputs lib;}; + inherit (lib.customisation) makeScope; + inherit (lib.attrsets) isDerivation isAttrs concatMapAttrs; + inherit (lib.strings) concatStringsSep; + inherit (lib.filesystem) packagesFromDirectoryRecursive; - # Helper function for creating demo configurations for nvf - # TODO: make this more generic. - buildPkg = maximal: - (args.config.flake.lib.nvim.neovimConfiguration { - inherit pkgs; - modules = [(import ../configuration.nix maximal)]; - }).neovim; + # Entrypoint for nvf documentation and relevant packages. + docs = import ../docs {inherit pkgs inputs lib;}; - # This constructs a by-name overlay similar to the one found in Nixpkgs. - # The goal is to automatically discover and packages found in pkgs/by-name - # as long as they have a 'package.nix' in the package directory. We also - # pass 'inputs' and 'pins' to all packages in the 'callPackage' scope, therefore - # they are always available in the relevant 'package.nix' files. - # --- - # The logic is borrowed from drupol/pkgs-by-name-for-flake-parts, available - # under the MIT license. - flattenPkgs = separator: path: value: - if isDerivation value - then { - ${concatStringsSep separator path} = value; - } - else if isAttrs value - then concatMapAttrs (name: flattenPkgs separator (path ++ [name])) value - else - # Ignore the functions which makeScope returns - {}; + # Helper function for creating demo configurations for nvf + # TODO: make this more generic. + buildPkg = maximal: + (lib.nvim.neovimConfiguration { + inherit pkgs; + modules = [(import ../configuration.nix maximal)]; + }).neovim; - inputsScope = makeScope pkgs.newScope (_: { - inherit inputs; - inherit (self) pins; - }); + # This constructs a by-name overlay similar to the one found in Nixpkgs. + # The goal is to automatically discover and packages found in pkgs/by-name + # as long as they have a 'package.nix' in the package directory. We also + # pass 'inputs' and 'pins' to all packages in the 'callPackage' scope, therefore + # they are always available in the relevant 'package.nix' files. + # --- + # The logic is borrowed from drupol/pkgs-by-name-for-flake-parts, available + # under the MIT license. + flattenPkgs = separator: path: value: + if isDerivation value + then { + ${concatStringsSep separator path} = value; + } + else if isAttrs value + then concatMapAttrs (name: flattenPkgs separator (path ++ [name])) value + else + # Ignore the functions which makeScope returns + {}; - scopeFromDirectory = directory: - packagesFromDirectoryRecursive { - inherit directory; - inherit (inputsScope) newScope callPackage; + inputsScope = makeScope pkgs.newScope (_: { + inherit inputs; + inherit (self) pins; + }); + + scopeFromDirectory = directory: + packagesFromDirectoryRecursive { + inherit directory; + inherit (inputsScope) newScope callPackage; + }; + + legacyPackages = scopeFromDirectory ./pkgs/by-name; +in + (flattenPkgs "/" [] legacyPackages) + // { + inherit (docs.manual) htmlOpenTool; + + # Documentation + docs = docs.manual.html; + docs-html = docs.manual.html; + docs-manpages = docs.manPages; + docs-json = docs.options.json; + docs-linkcheck = let + site = self.packages.${system}.docs; + in + pkgs.testers.lycheeLinkCheck { + inherit site; + + remap = { + "https://notashelf.github.io/nvf/" = "${site}/share/doc/"; + "https://nvf.notashelf.dev/" = "${site}/share/doc/"; + }; + + extraConfig = { + exclude = [ + # This is not an email, but just part of an SCM query inside a nix code block. + # The leading escaped non breaking space is there on purpose. + "%C2%A0@injection.content" + ]; + include_mail = true; + include_verbatim = true; + }; }; - legacyPackages = scopeFromDirectory ./pkgs/by-name; - in { - packages = - (flattenPkgs "/" [] legacyPackages) - // { - inherit (docs.manual) htmlOpenTool; + # Helper utility for building the HTML manual and opening it in the + # browser with $BROWSER or using xdg-open as a fallback tool. + # Adapted from Home-Manager, available under the MIT license. + docs-html-wrapped = let + xdg-open = lib.getExe' pkgs.xdg-utils "xdg-open"; + docs-html = docs.manual.html + /share/doc/nvf; + in + pkgs.writeShellScriptBin "docs-html-wrapped" '' + set -euo pipefail - # Documentation - docs = docs.manual.html; - docs-html = docs.manual.html; - docs-manpages = docs.manPages; - docs-json = docs.options.json; - docs-linkcheck = let - site = config.packages.docs; - in - pkgs.testers.lycheeLinkCheck { - inherit site; - - remap = { - "https://notashelf.github.io/nvf/" = "${site}/share/doc/"; - "https://nvf.notashelf.dev/" = "${site}/share/doc/"; - }; - - extraConfig = { - exclude = [ - # This is not an email, but just part of an SCM query inside a nix code block. - # The leading escaped non breaking space is there on purpose. - "%C2%A0@injection.content" - ]; - include_mail = true; - include_verbatim = true; - }; - }; - - # Helper utility for building the HTML manual and opening it in the - # browser with $BROWSER or using xdg-open as a fallback tool. - # Adapted from Home-Manager, available under the MIT license. - docs-html-wrapped = let - xdg-open = lib.getExe' pkgs.xdg-utils "xdg-open"; - docs-html = docs.manual.html + /share/doc/nvf; - in - pkgs.writeShellScriptBin "docs-html-wrapped" '' - set -euo pipefail - - if [[ ! -v BROWSER || -z $BROWSER ]]; then - for candidate in xdg-open open w3m; do - BROWSER="$(type -P $candidate || true)" - if [[ -x $BROWSER ]]; then - break; - fi - done + if [[ ! -v BROWSER || -z $BROWSER ]]; then + for candidate in xdg-open open w3m; do + BROWSER="$(type -P $candidate || true)" + if [[ -x $BROWSER ]]; then + break; fi + done + fi - if [[ ! -v BROWSER || -z $BROWSER ]]; then - echo "$0: unable to start a web browser; please set \$BROWSER" - echo "$0: Trying xdg-open as a fallback" - ${xdg-open} ${docs-html}/index.xhtml - else - echo "\$BROWSER is set. Attempting to open manual" - exec "$BROWSER" "${docs-html}/index.xhtml" - fi - ''; + if [[ ! -v BROWSER || -z $BROWSER ]]; then + echo "$0: unable to start a web browser; please set \$BROWSER" + echo "$0: Trying xdg-open as a fallback" + ${xdg-open} ${docs-html}/index.xhtml + else + echo "\$BROWSER is set. Attempting to open manual" + exec "$BROWSER" "${docs-html}/index.xhtml" + fi + ''; - # Exposed neovim configurations - nix = buildPkg false; - maximal = buildPkg true; - default = config.packages.nix; - }; - }; -} + # Exposed neovim configurations + nix = buildPkg false; + maximal = buildPkg true; + default = self.packages.${system}.nix; + } diff --git a/flake/templates/default.nix b/flake/templates/default.nix index 58cd7fa7..60c8a085 100644 --- a/flake/templates/default.nix +++ b/flake/templates/default.nix @@ -1,17 +1,15 @@ { - flake.templates = { - standalone = { - path = ./standalone; - description = "Standalone flake template for nvf"; - welcomeText = '' - Template flake.nix has been created in flake.nix! + standalone = { + path = ./standalone; + description = "Standalone flake template for nvf"; + welcomeText = '' + Template flake.nix has been created in flake.nix! - Note that this is a very basic example to bootstrap nvf for you. Please edit your - configuration as described in the nvf manual before using this template. The - configured packages will be ran with 'nix run .' or 'nix run .#neovimConfigured' + Note that this is a very basic example to bootstrap nvf for you. Please edit your + configuration as described in the nvf manual before using this template. The + configured packages will be ran with 'nix run .' or 'nix run .#neovimConfigured' - Happy editing! - ''; - }; + Happy editing! + ''; }; }