From 5044f8d84b2b6296cc71fffcf1e24af5c6894c76 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Tue, 20 Apr 2021 12:26:59 -0500 Subject: [PATCH 1/3] init: devshell for hands-on onboarding --- devshell.toml | 19 +++++++++++++++++++ flake.nix | 5 +++++ shell.nix | 17 +++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 devshell.toml create mode 100644 shell.nix diff --git a/devshell.toml b/devshell.toml new file mode 100644 index 00000000000000..998a3cad71c03a --- /dev/null +++ b/devshell.toml @@ -0,0 +1,19 @@ +[devshell] +name = "nixpkgs" +packages = [ + "fd", + "nixpkgs-fmt", +] + +[[commands]] +name = "fmt" +help = "Check Nix formatting" +category = "linters" +command = "nixpkgs-fmt ${@} ." + +[[commands]] +name = "evalnix" +help = "Check Nix parsing" +category = "linters" +command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null" + diff --git a/flake.nix b/flake.nix index 537f91ee5e711c..a42e6f50fcfcd2 100644 --- a/flake.nix +++ b/flake.nix @@ -63,6 +63,11 @@ }); checks.x86_64-linux.tarball = jobs.tarball; + devShell = { + x86_64-linux = import ./shell.nix { system = "x86_64-linux"; }; + x86_64-darwin = import ./shell.nix { system = "x86_64-darwin"; }; + aarch64-linux = import ./shell.nix { system = "aarch64-linux"; }; + }; htmlDocs = { nixpkgsManual = jobs.manual; diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000000000..219445ea6c18dd --- /dev/null +++ b/shell.nix @@ -0,0 +1,17 @@ +{ system ? builtins.currentSystem }: +let + # nixpkgs / devshell is only used for development. Don't add it to the flake.lock. + devshellGitRev = "709fe4d04a9101c9d224ad83f73416dce71baf21"; + + nixpkgsSrc = ./.; + + devshellSrc = fetchTarball { + url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz"; + sha256 = "1px9cqfshfqs1b7ypyxch3s3ymr4xgycy1krrcg7b97rmmszvsqr"; + }; + + pkgs = import nixpkgsSrc { inherit system; }; + devshell = import devshellSrc { inherit system pkgs; }; + +in +devshell.fromTOML ./devshell.toml From b9bd4496673bdbf612ad632a7c2d2b56764703ee Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 21 Apr 2021 17:53:44 -0500 Subject: [PATCH 2/3] devhsell: pin nixpkgs version it would be too costly for users to rebuild the devshell on every change in nixpkgs. Also, an unpinned nixpkgs version might suddenly become broken if nixpkgs changes in ways that devshell is not yet compatible with. --- shell.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index 219445ea6c18dd..ae581b677a18ab 100644 --- a/shell.nix +++ b/shell.nix @@ -1,9 +1,14 @@ { system ? builtins.currentSystem }: let # nixpkgs / devshell is only used for development. Don't add it to the flake.lock. + nixpkgsGitRev = "5268ee2ebacbc73875be42d71e60c2b5c1b5a1c7"; devshellGitRev = "709fe4d04a9101c9d224ad83f73416dce71baf21"; - nixpkgsSrc = ./.; + nixpkgsSrc = fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsGitRev}.tar.gz"; + sha256 = "080fvmg0i6z01h6adddfrjp1bbbjhhqk32ks6ch9gv689645ccfq"; + }; + devshellSrc = fetchTarball { url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz"; From 4c244841ff0d68bbb06b1a8c2c1dfbf882b99625 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 21 Apr 2021 17:57:27 -0500 Subject: [PATCH 3/3] devshell: use good old nix --- devshell.toml | 19 ------------------- shell.nix | 25 ++++++++++++++++++++++++- 2 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 devshell.toml diff --git a/devshell.toml b/devshell.toml deleted file mode 100644 index 998a3cad71c03a..00000000000000 --- a/devshell.toml +++ /dev/null @@ -1,19 +0,0 @@ -[devshell] -name = "nixpkgs" -packages = [ - "fd", - "nixpkgs-fmt", -] - -[[commands]] -name = "fmt" -help = "Check Nix formatting" -category = "linters" -command = "nixpkgs-fmt ${@} ." - -[[commands]] -name = "evalnix" -help = "Check Nix parsing" -category = "linters" -command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null" - diff --git a/shell.nix b/shell.nix index ae581b677a18ab..f4dab104bf8038 100644 --- a/shell.nix +++ b/shell.nix @@ -19,4 +19,27 @@ let devshell = import devshellSrc { inherit system pkgs; }; in -devshell.fromTOML ./devshell.toml +devshell.mkShell { + devshell = { + name = "nixpkgs"; + packages = with pkgs; [ + fd + nixpkgs-fmt + ]; + }; + + commands = [ + { + name = "fmt"; + help = "Check Nix formatting"; + category = "linters"; + command = "nixpkgs-fmt $${@} ."; + } + { + name = "evalnix"; + help = "Check Nix parsing"; + category = "linters"; + command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null"; + } + ]; +}