From be35fad15de0b5049b597ab9baf5255292c6904f Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Thu, 11 May 2023 01:04:05 +0200 Subject: [PATCH] refactor: flake.parts! --- .github/workflows/build.yml | 18 ---------- flake.lock | 37 ++++++++++++++++++++ flake.nix | 54 +++++++++++++++++++++--------- overlay.nix | 19 ----------- packages.nix | 16 --------- packages/agilebits-op.nix | 2 +- packages/anonymous-overflow.nix | 2 +- packages/cliclick.nix | 2 +- packages/fennel-ls.nix | 2 +- packages/liblpeg-darwin.nix | 2 +- packages/neovim-nightly.nix | 12 +++---- packages/nitter-unstable.nix | 2 +- packages/phantomjs.nix | 2 +- packages/q.nix | 2 +- packages/rimgo.nix | 2 +- packages/website-docs-nifoc-pw.nix | 4 +-- 16 files changed, 91 insertions(+), 87 deletions(-) delete mode 100644 overlay.nix delete mode 100644 packages.nix diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0950460..f8f0bd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,24 +27,6 @@ jobs: - run: nix build '.#rimgo' - run: nix build '.#website-docs-nifoc-pw' - build-x86_64-darwin: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - uses: cachix/cachix-action@v12 - with: - name: nifoc - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - run: nix build '.#cliclick' - - run: nix build '.#fennel-ls' - - run: nix build '.#liblpeg-darwin' - - run: nix build '.#neovim-nightly' - - run: nix build '.#phantomjs' - - run: nix build '.#q' - build-arm64-linux: runs-on: buildjet-2vcpu-ubuntu-2204-arm steps: diff --git a/flake.lock b/flake.lock index c090280..4517940 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1683560683, + "narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "006c75898cf814ef9497252b022e91c946ba8e17", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -54,8 +72,27 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1682879489, + "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { + "flake-parts": "flake-parts", "neovim-flake": "neovim-flake", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 7f90c13..bd03db8 100644 --- a/flake.nix +++ b/flake.nix @@ -3,31 +3,55 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + neovim-flake = { url = "github:neovim/neovim?dir=contrib"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = inputs@{ self, nixpkgs, ... }: { - packages = nixpkgs.lib.genAttrs - [ + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "aarch64-darwin" "x86_64-darwin" - "aarch64-linux" "x86_64-linux" - ] - (system: import ./packages.nix { - inherit system; - inherit (nixpkgs) lib; + "aarch64-linux" + ]; - pkgs = nixpkgs.legacyPackages.${system}; + imports = [ + flake-parts.flakeModules.easyOverlay + ]; - otherPkgs = { - neovim = inputs.neovim-flake.packages.${system}; - }; - }); + perSystem = { inputs', system, config, pkgs, lib, ... }: { + packages = + let + darwinPackages = + if lib.hasSuffix "darwin" system then rec { + agilebits-op = import ./packages/agilebits-op.nix { inherit pkgs lib; }; + cliclick = import ./packages/cliclick.nix { inherit pkgs lib; }; + liblpeg = import ./packages/liblpeg-darwin.nix { inherit pkgs; }; + neovim-nightly = import ./packages/neovim-nightly.nix { inherit (inputs'.neovim-flake.packages) neovim; inherit liblpeg lib; }; + phantomjs = import ./packages/phantomjs.nix { inherit pkgs lib; }; + } else { + neovim-nightly = import ./packages/neovim-nightly.nix { inherit (inputs'.neovim-flake.packages) neovim; inherit lib; }; + }; + in + { + anonymous-overflow = import ./packages/anonymous-overflow.nix { inherit pkgs lib; }; + fennel-ls = import ./packages/fennel-ls.nix { inherit pkgs lib; }; + nitter-unstable = import ./packages/nitter-unstable.nix { inherit pkgs lib; }; + q = import ./packages/q.nix { inherit pkgs lib; }; + rimgo = import ./packages/rimgo.nix { inherit pkgs lib; }; + website-docs-nifoc-pw = import ./packages/website-docs-nifoc-pw.nix { inherit pkgs; }; + } // darwinPackages; - overlay = import ./overlay.nix; - }; + overlayAttrs = config.packages; + }; + + flake = { + overlay = inputs.self.overlays.default; + }; + }; } diff --git a/overlay.nix b/overlay.nix deleted file mode 100644 index 08efb37..0000000 --- a/overlay.nix +++ /dev/null @@ -1,19 +0,0 @@ -_: super: - -let - custom = super.callPackage ./packages.nix { }; -in -{ - inherit (custom) agilebits-op; - inherit (custom) anonymous-overflow; - inherit (custom) cliclick; - inherit (custom) fennel-ls; - inherit (custom) nitter-unstable; - inherit (custom) phantomjs; - inherit (custom) q; - inherit (custom) rimgo; - inherit (custom) website-docs-nifoc-pw; - - inherit (custom) liblpeg-darwin; - inherit (custom) neovim-nightly; -} diff --git a/packages.nix b/packages.nix deleted file mode 100644 index 3a191d4..0000000 --- a/packages.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ system, lib, pkgs, otherPkgs }: - -rec { - agilebits-op = import ./packages/agilebits-op.nix { inherit system lib pkgs; }; - anonymous-overflow = import ./packages/anonymous-overflow.nix { inherit system lib pkgs; }; - cliclick = import ./packages/cliclick.nix { inherit system lib pkgs; }; - fennel-ls = import ./packages/fennel-ls.nix { inherit system lib pkgs; }; - nitter-unstable = import ./packages/nitter-unstable.nix { inherit system lib pkgs; }; - phantomjs = import ./packages/phantomjs.nix { inherit system lib pkgs; }; - q = import ./packages/q.nix { inherit system lib pkgs; }; - rimgo = import ./packages/rimgo.nix { inherit system lib pkgs; }; - website-docs-nifoc-pw = import ./packages/website-docs-nifoc-pw.nix { inherit system lib pkgs; }; - - liblpeg-darwin = import ./packages/liblpeg-darwin.nix { inherit system lib pkgs; }; - neovim-nightly = import ./packages/neovim-nightly.nix { inherit system lib pkgs otherPkgs liblpeg-darwin; }; -} diff --git a/packages/agilebits-op.nix b/packages/agilebits-op.nix index c260f33..3d86190 100644 --- a/packages/agilebits-op.nix +++ b/packages/agilebits-op.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.stdenv.mkDerivation rec { pname = "agilebits-op"; diff --git a/packages/anonymous-overflow.nix b/packages/anonymous-overflow.nix index 1dd232e..c172e01 100644 --- a/packages/anonymous-overflow.nix +++ b/packages/anonymous-overflow.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.buildGoModule rec { pname = "anonymous-overflow"; diff --git a/packages/cliclick.nix b/packages/cliclick.nix index 5c7dbf1..0ac3732 100644 --- a/packages/cliclick.nix +++ b/packages/cliclick.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.stdenv.mkDerivation rec { pname = "cliclick"; diff --git a/packages/fennel-ls.nix b/packages/fennel-ls.nix index 20bd4a6..505df47 100644 --- a/packages/fennel-ls.nix +++ b/packages/fennel-ls.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.stdenv.mkDerivation rec { pname = "fennel-ls"; diff --git a/packages/liblpeg-darwin.nix b/packages/liblpeg-darwin.nix index 00123f9..8bd3c9c 100644 --- a/packages/liblpeg-darwin.nix +++ b/packages/liblpeg-darwin.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs }: pkgs.stdenv.mkDerivation { pname = "liblpeg"; diff --git a/packages/neovim-nightly.nix b/packages/neovim-nightly.nix index a2f3232..d2d96d1 100644 --- a/packages/neovim-nightly.nix +++ b/packages/neovim-nightly.nix @@ -1,12 +1,8 @@ -{ pkgs, otherPkgs, lib, liblpeg-darwin, ... }: +{ neovim, liblpeg ? null, lib, ... }: -let - inherit (pkgs.stdenv) isDarwin; - inherit (lib) optionals; -in -otherPkgs.neovim.neovim.overrideAttrs (oa: { - nativeBuildInputs = oa.nativeBuildInputs ++ optionals isDarwin [ - liblpeg-darwin +neovim.overrideAttrs (oa: { + nativeBuildInputs = oa.nativeBuildInputs ++ lib.optionals (liblpeg != null) [ + liblpeg ]; patches = builtins.filter diff --git a/packages/nitter-unstable.nix b/packages/nitter-unstable.nix index e34d64e..6766b2a 100644 --- a/packages/nitter-unstable.nix +++ b/packages/nitter-unstable.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: let nimPackages = pkgs.nimPackages; diff --git a/packages/phantomjs.nix b/packages/phantomjs.nix index 618ebbe..64cd8d2 100644 --- a/packages/phantomjs.nix +++ b/packages/phantomjs.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.stdenv.mkDerivation rec { pname = "phantomjs"; diff --git a/packages/q.nix b/packages/q.nix index 1af6120..cd2cc39 100644 --- a/packages/q.nix +++ b/packages/q.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.buildGoModule rec { pname = "q"; diff --git a/packages/rimgo.nix b/packages/rimgo.nix index 8982639..450ebc1 100644 --- a/packages/rimgo.nix +++ b/packages/rimgo.nix @@ -1,4 +1,4 @@ -{ system, lib, pkgs }: +{ pkgs, lib }: pkgs.buildGoModule rec { pname = "rimgo"; diff --git a/packages/website-docs-nifoc-pw.nix b/packages/website-docs-nifoc-pw.nix index 2661e0d..c02eb44 100644 --- a/packages/website-docs-nifoc-pw.nix +++ b/packages/website-docs-nifoc-pw.nix @@ -1,6 +1,6 @@ -{ system, lib, pkgs }: +{ pkgs }: -pkgs.stdenv.mkDerivation rec { +pkgs.stdenv.mkDerivation { pname = "website-docs-nifoc-pw"; version = "2021-08-30";