Merge pull request #54 from nrdxp/devshell

Use mkDevShell for shell.nix
This commit is contained in:
Timothy DeHerrera 2020-12-28 23:15:03 -07:00 committed by GitHub
commit 165ffaa4fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 32 deletions

17
compat/fetch.nix Normal file
View File

@ -0,0 +1,17 @@
let
inherit (builtins)
fetchTarball
fromJSON
readFile
;
lockfile = fromJSON (readFile ../flake.lock);
in
input:
let
locked = lockfile.nodes."${input}".locked;
inherit (locked) rev narHash owner repo;
in
fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
}

5
compat/nixpkgs.nix Normal file
View File

@ -0,0 +1,5 @@
let
fetch = import ./fetch.nix;
nixpkgs = fetch "nixos";
in
nixpkgs

View File

@ -1,5 +1,20 @@
{ {
"nodes": { "nodes": {
"devshell": {
"locked": {
"lastModified": 1607956014,
"narHash": "sha256-kcmh1ZO56GFYStDeM2VngJSvx/e8aKhFSYqLwfiq+Es=",
"owner": "numtide",
"repo": "devshell",
"rev": "17f46732ce299daa2977be2978f60d258c2d1b41",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1605370193, "lastModified": 1605370193,
@ -93,6 +108,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"home": "home", "home": "home",
"master": "master", "master": "master",

View File

@ -7,9 +7,10 @@
nixos.url = "nixpkgs/release-20.09"; nixos.url = "nixpkgs/release-20.09";
home.url = "github:nix-community/home-manager/release-20.09"; home.url = "github:nix-community/home-manager/release-20.09";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
}; };
outputs = inputs@{ self, home, nixos, master, flake-utils, nur }: outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell }:
let let
inherit (builtins) attrNames attrValues readDir elem pathExists filter; inherit (builtins) attrNames attrValues readDir elem pathExists filter;
inherit (flake-utils.lib) eachDefaultSystem mkApp; inherit (flake-utils.lib) eachDefaultSystem mkApp;
@ -23,7 +24,7 @@
system = "x86_64-linux"; system = "x86_64-linux";
externOverlays = [ nur.overlay ]; externOverlays = [ nur.overlay devshell.overlay ];
externModules = [ home.nixosModules.home-manager ]; externModules = [ home.nixosModules.home-manager ];
pkgset = pkgset =
@ -57,7 +58,7 @@
pkgs' = pkgImport { pkgs' = pkgImport {
pkgs = master; pkgs = master;
system = system'; system = system';
overlays = [ ]; overlays = [ devshell.overlay ];
}; };
packages' = genPackages { packages' = genPackages {
@ -79,7 +80,6 @@
{ {
devShell = import ./shell.nix { devShell = import ./shell.nix {
pkgs = pkgs'; pkgs = pkgs';
nixpkgs = nixos;
}; };
apps = apps =

View File

@ -1,13 +0,0 @@
let
inherit (builtins)
fetchTarball
fromJSON
readFile
;
nixos = (fromJSON (readFile ./flake.lock)).nodes.nixos.locked;
nixpkgs = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${nixos.rev}.tar.gz";
sha256 = nixos.narHash;
};
in
nixpkgs

View File

@ -46,6 +46,7 @@ in
systemPackages = with pkgs; [ systemPackages = with pkgs; [
bat bat
bzip2 bzip2
devshell
exa exa
gitAndTools.hub gitAndTools.hub
gzip gzip

View File

@ -1,7 +1,11 @@
let let
nixpkgs' = import ./nixpkgs-compat.nix; nixpkgs = import ./compat/nixpkgs.nix;
fetch = import ./compat/fetch.nix;
devshell' = fetch "devshell";
pkgs' = import devshell' { inherit nixpkgs; };
in in
{ pkgs ? import nixpkgs { }, nixpkgs ? nixpkgs' }: { pkgs ? pkgs', ... }:
let let
configs = "${toString ./.}#nixosConfigurations"; configs = "${toString ./.}#nixosConfigurations";
build = "config.system.build"; build = "config.system.build";
@ -22,14 +26,20 @@ let
sudo nixos-rebuild --flake ".#$1" $@ sudo nixos-rebuild --flake ".#$1" $@
fi fi
''; '';
nix = pkgs.writeShellScriptBin "nix" ''
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
'';
in in
pkgs.mkShell { pkgs.mkDevShell {
name = "nixflk"; name = "nixflk";
nativeBuildInputs = with pkgs; with installPkgs; [
packages = with pkgs; with installPkgs; [
git git
git-crypt git-crypt
flk flk
nix-zsh-completions nix
nixpkgs-fmt
python38Packages.grip python38Packages.grip
nixos-install nixos-install
nixos-generate-config nixos-generate-config
@ -37,14 +47,6 @@ pkgs.mkShell {
nixos-rebuild nixos-rebuild
]; ];
shellHook = '' env = { };
mkdir -p secrets
if ! nix flake show &> /dev/null; then
PATH=${
pkgs.writeShellScriptBin "nix" ''
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
''
}/bin:$PATH
fi
'';
} }