Skip to content
forked from divnix/digga

Commit 1551a2f

Browse files
authored
Merge pull request divnix#54 from nrdxp/devshell
Use mkDevShell for shell.nix
2 parents f41e5a5 + 28d12f0 commit 1551a2f

File tree

5 files changed

+59
-19
lines changed

5 files changed

+59
-19
lines changed

compat/fetch.nix

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let
2+
inherit (builtins)
3+
fetchTarball
4+
fromJSON
5+
readFile
6+
;
7+
lockfile = fromJSON (readFile ../flake.lock);
8+
in
9+
input:
10+
let
11+
locked = lockfile.nodes."${input}".locked;
12+
inherit (locked) rev narHash owner repo;
13+
in
14+
fetchTarball {
15+
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
16+
sha256 = narHash;
17+
}

compat/nixpkgs.nix

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let
2+
fetch = import ./fetch.nix;
3+
nixpkgs = fetch "nixos";
4+
in
5+
nixpkgs

flake.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
nixos.url = "nixpkgs/release-20.09";
88
home.url = "github:nix-community/home-manager/release-20.09";
99
flake-utils.url = "github:numtide/flake-utils";
10+
devshell.url = "github:numtide/devshell";
1011
};
1112

12-
outputs = inputs@{ self, home, nixos, master, flake-utils, nur }:
13+
outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell }:
1314
let
1415
inherit (builtins) attrNames attrValues readDir elem pathExists filter;
1516
inherit (flake-utils.lib) eachDefaultSystem mkApp;
@@ -23,7 +24,7 @@
2324

2425
system = "x86_64-linux";
2526

26-
externOverlays = [ nur.overlay ];
27+
externOverlays = [ nur.overlay devshell.overlay ];
2728
externModules = [ home.nixosModules.home-manager ];
2829

2930
pkgset =
@@ -57,7 +58,7 @@
5758
pkgs' = pkgImport {
5859
pkgs = master;
5960
system = system';
60-
overlays = [ ];
61+
overlays = [ devshell.overlay ];
6162
};
6263

6364
packages' = genPackages {
@@ -79,7 +80,6 @@
7980
{
8081
devShell = import ./shell.nix {
8182
pkgs = pkgs';
82-
nixpkgs = nixos;
8383
};
8484

8585
apps =

shell.nix

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
let
2-
nixpkgs' = import ./nixpkgs-compat.nix;
2+
nixpkgs = import ./compat/nixpkgs.nix;
3+
fetch = import ./compat/fetch.nix;
4+
5+
devshell' = fetch "devshell";
6+
pkgs' = import devshell' { inherit nixpkgs; };
37
in
4-
{ pkgs ? import nixpkgs { }, nixpkgs ? nixpkgs' }:
8+
{ pkgs ? pkgs', ... }:
59
let
610
configs = "${toString ./.}#nixosConfigurations";
711
build = "config.system.build";
@@ -22,29 +26,27 @@ let
2226
sudo nixos-rebuild --flake ".#$1" $@
2327
fi
2428
'';
29+
30+
nix = pkgs.writeShellScriptBin "nix" ''
31+
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
32+
'';
2533
in
26-
pkgs.mkShell {
34+
pkgs.mkDevShell {
2735
name = "nixflk";
28-
nativeBuildInputs = with pkgs; with installPkgs; [
36+
37+
packages = with pkgs; with installPkgs; [
2938
git
3039
git-crypt
3140
flk
32-
nix-zsh-completions
41+
nix
42+
nixpkgs-fmt
3343
python38Packages.grip
3444
nixos-install
3545
nixos-generate-config
3646
nixos-enter
3747
nixos-rebuild
3848
];
3949

40-
shellHook = ''
41-
mkdir -p secrets
42-
if ! nix flake show &> /dev/null; then
43-
PATH=${
44-
pkgs.writeShellScriptBin "nix" ''
45-
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
46-
''
47-
}/bin:$PATH
48-
fi
49-
'';
50+
env = { };
51+
5052
}

0 commit comments

Comments
 (0)