From 14bc2d39de959597fbb405eb8ff2a3e5ff8fc340 Mon Sep 17 00:00:00 2001 From: LeMarsu Date: Sat, 3 May 2025 14:42:41 +0200 Subject: [PATCH] chore(nix): move to flake-parts --- dev/default.nix | 6 +++++ dev/formatter.nix | 5 ++++ dev/shell.nix | 12 +++++++++ flake.lock | 68 +++++++++++++++++++++++------------------------ flake.nix | 36 +++++++------------------ lib/default.nix | 20 ++++++++++---- shell.nix | 10 ------- 7 files changed, 81 insertions(+), 76 deletions(-) create mode 100644 dev/default.nix create mode 100644 dev/formatter.nix create mode 100644 dev/shell.nix delete mode 100644 shell.nix diff --git a/dev/default.nix b/dev/default.nix new file mode 100644 index 0000000..a0286e3 --- /dev/null +++ b/dev/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./formatter.nix + ./shell.nix + ]; +} diff --git a/dev/formatter.nix b/dev/formatter.nix new file mode 100644 index 0000000..84c51af --- /dev/null +++ b/dev/formatter.nix @@ -0,0 +1,5 @@ +{ + perSystem = {pkgs, ...}: { + formatter = pkgs.alejandra; + }; +} diff --git a/dev/shell.nix b/dev/shell.nix new file mode 100644 index 0000000..8727610 --- /dev/null +++ b/dev/shell.nix @@ -0,0 +1,12 @@ +{ + perSystem = {pkgs, ...}: { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + alejandra + git-cliff + nil + sumneko-lua-language-server + ]; + }; + }; +} diff --git a/flake.lock b/flake.lock index 6ef1fba..1ea8835 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1739020877, @@ -16,6 +34,21 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1660438583, @@ -33,44 +66,11 @@ }, "root": { "inputs": { + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", - "utils": "utils", "yants": "yants" } }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "yants": { "inputs": { "nixpkgs": "nixpkgs_2" diff --git a/flake.nix b/flake.nix index 40b0b57..4779fb8 100644 --- a/flake.nix +++ b/flake.nix @@ -3,35 +3,17 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - utils.url = "github:numtide/flake-utils"; yants.url = "github:divnix/yants"; + flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = { - self, - nixpkgs, - utils, - yants, - ... - } @ inputs: let - inherit (builtins) readFile replaceStrings; - fu = utils.lib; - versionFile = replaceStrings ["\n"] [""] (readFile ./VERSION); - version = - if self.sourceInfo ? dirtyShortRev - then "${versionFile}-${self.sourceInfo.dirtyShortRev}" - else versionFile; + outputs = {flake-parts, ...} @ inputs: let + in (flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux"]; - forSystem = system: let - pkgs = nixpkgs.legacyPackages.${system}; - inherit (pkgs) nil; - in { - formatter = pkgs.alejandra; - devShells.default = import ./shell.nix { - inherit pkgs; - }; - }; - in - (fu.eachDefaultSystem forSystem) - // {lib = import ./lib {inherit version yants;};}; + imports = [ + ./dev + ./lib + ]; + }); } diff --git a/lib/default.nix b/lib/default.nix index 7de3ae6..15f3192 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,9 +1,19 @@ { - version, - yants, + self, + inputs, + ... }: let - types = import ./types.nix {inherit yants;}; + inherit (builtins) readFile replaceStrings; + versionFile = replaceStrings ["\n"] [""] (readFile ../VERSION); + version = + if self.sourceInfo ? dirtyShortRev + then "${versionFile}-${self.sourceInfo.dirtyShortRev}" + else versionFile; + + types = import ./types.nix {inherit (inputs) yants;}; in { - mkNeovimPkg = import ./mkNeovimPkg.nix {inherit version types;}; - mkPluginsFromInputs = import ./mkPluginsFromInputs.nix; + flake.lib = { + mkNeovimPkg = import ./mkNeovimPkg.nix {inherit version types;}; + mkPluginsFromInputs = import ./mkPluginsFromInputs.nix; + }; } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 0f01d70..0000000 --- a/shell.nix +++ /dev/null @@ -1,10 +0,0 @@ -{pkgs, ...}: -with pkgs; - mkShell { - buildInputs = [ - alejandra - git-cliff - nil - sumneko-lua-language-server - ]; - }