From 5a34a7a3f7a0b5914049f183673d60ffb54060e0 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 3 Apr 2023 21:27:24 +0100 Subject: [PATCH] build: use a Nix flake and `flake-parts` --- .yarnrc | 1 - flake.lock | 89 ++++++++++++++++++++++++++++++++++++++++++++++++------ flake.nix | 30 ++++++++---------- 3 files changed, 93 insertions(+), 27 deletions(-) delete mode 100644 .yarnrc diff --git a/.yarnrc b/.yarnrc deleted file mode 100644 index 04aaf4e0..00000000 --- a/.yarnrc +++ /dev/null @@ -1 +0,0 @@ ---modules-folder /node_modules diff --git a/flake.lock b/flake.lock index a67eb96d..f9d3e95e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,48 @@ { "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1678957337, + "narHash": "sha256-Gw4nVbuKRdTwPngeOZQOzH/IFowmz4LryMPDiJN/ah4=", + "owner": "numtide", + "repo": "devshell", + "rev": "3e0e60ab37cd0bf7ab59888f5c32499d851edb47", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1680392223, + "narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, "flake-utils": { "locked": { - "lastModified": 1678901627, - "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", "owner": "numtide", "repo": "flake-utils", - "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", "type": "github" }, "original": { @@ -17,24 +53,59 @@ }, "nixpkgs": { "locked": { - "lastModified": 1679431620, - "narHash": "sha256-n3K48VgwjlXmDUica6FMgBHMeftDgcSTtFe+lnIcwOY=", + "lastModified": 1677383253, + "narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e97bb3fb6b9c5fff48247c15d19493839447a0e2", + "rev": "9952d6bc395f5841262b006fbace8dd7e143b634", "type": "github" }, "original": { "owner": "NixOS", - "ref": "master", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1680213900, + "narHash": "sha256-cIDr5WZIj3EkKyCgj/6j3HBH4Jj1W296z7HTcWj1aMA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e3652e0735fbec227f342712f180f4f21f0594f2", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1680213900, + "narHash": "sha256-cIDr5WZIj3EkKyCgj/6j3HBH4Jj1W296z7HTcWj1aMA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e3652e0735fbec227f342712f180f4f21f0594f2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "devshell": "devshell", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_2" } } }, diff --git a/flake.nix b/flake.nix index d887d75e..ff1c2125 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,17 @@ { - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/master"; - flake-utils.url = "github:numtide/flake-utils"; - }; + inputs.devshell.url = "github:numtide/devshell"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - devShell = with pkgs; pkgs.mkShell { - buildInputs = [ - just - nodejs-19_x - yarn - ]; + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ inputs.devshell.flakeModule ]; + + systems = [ "x86_64-linux" ]; + + perSystem = { config, self', inputs', pkgs, system, ... }: { + devshells.default = { + packages = with pkgs; [ just nodejs-19_x yarn ]; }; - }); + }; + }; }