Use numtide/devshell instead of pkgs.mkShell
This commit is contained in:
parent
8355526d27
commit
c512c63fdb
39
flake.lock
generated
39
flake.lock
generated
@ -42,6 +42,27 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs-unstable"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1644227066,
|
||||
"narHash": "sha256-FHcFZtpZEWnUh62xlyY3jfXAXHzJNEDLDzLsJxn+ve0=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "7033f64dd9ef8d9d8644c5030c73913351d2b660",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@ -59,6 +80,21 @@
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1642700792,
|
||||
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
@ -208,7 +244,8 @@
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"deploy-rs": "deploy-rs",
|
||||
"flake-utils": "flake-utils",
|
||||
"devshell": "devshell",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"home-manager": "home-manager",
|
||||
"impermanence": "impermanence",
|
||||
"nix": "nix",
|
||||
|
70
flake.nix
70
flake.nix
@ -3,6 +3,8 @@
|
||||
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
devshell.url = "github:numtide/devshell";
|
||||
devshell.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
# Used by most systems
|
||||
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
|
||||
# For extra-stable systems
|
||||
@ -35,7 +37,7 @@
|
||||
let
|
||||
inherit (builtins) mapAttrs attrValues;
|
||||
inherit (lib.flake) eachDefaultSystem;
|
||||
inherit (lib.my) mkApp mkShellApp mkShellApp' inlineModules mkDefaultSystemsPkgs flakePackageOverlay;
|
||||
inherit (lib.my) attrsToList mkApp mkShellApp mkShellApp' inlineModules mkDefaultSystemsPkgs flakePackageOverlay;
|
||||
|
||||
extendLib = lib: lib.extend (final: prev: {
|
||||
my = import ./util.nix { lib = final; };
|
||||
@ -54,6 +56,7 @@
|
||||
(_: path: mkDefaultSystemsPkgs path (system: {
|
||||
overlays = [
|
||||
libOverlay
|
||||
inputs.devshell.overlay
|
||||
inputs.agenix.overlay
|
||||
inputs.deploy-rs.overlay
|
||||
inputs.nix.overlay
|
||||
@ -115,36 +118,59 @@
|
||||
in
|
||||
# Stuff for each platform
|
||||
{
|
||||
apps = {
|
||||
fmt = mkShellApp pkgs "fmt" ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@" .'';
|
||||
link = mkShellApp' pkgs {
|
||||
name = "install-home-link";
|
||||
runtimeInputs = [ pkgs.coreutils ];
|
||||
text =
|
||||
devShell = pkgs.devshell.mkShell {
|
||||
env = attrsToList {
|
||||
# starship will show this
|
||||
name = "devshell";
|
||||
|
||||
NIX_USER_CONF_FILES = toString (pkgs.writeText "nix.conf"
|
||||
''
|
||||
[ -e "${homeFlake}" ] && echo "${homeFlake} already exists" && exit 1
|
||||
|
||||
mkdir -p "$(dirname "${homeFlake}")"
|
||||
ln -s "$(pwd)/flake.nix" "${homeFlake}"
|
||||
echo "Installed link to $(pwd)/flake.nix at ${homeFlake}"
|
||||
'';
|
||||
experimental-features = nix-command flakes ca-derivations
|
||||
'');
|
||||
};
|
||||
unlink = mkShellApp pkgs "remove-home-link" ''rm -f ${homeFlake}'';
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
NIX_USER_CONF_FILES = pkgs.writeText "nix.conf"
|
||||
''
|
||||
experimental-features = nix-command flakes ca-derivations
|
||||
'';
|
||||
|
||||
packages = with pkgs; [
|
||||
coreutils
|
||||
nix
|
||||
agenix
|
||||
deploy-rs.deploy-rs
|
||||
nixpkgs-fmt
|
||||
home-manager
|
||||
];
|
||||
|
||||
commands = [
|
||||
{
|
||||
name = "home-link";
|
||||
category = "utilities";
|
||||
help = "Install link to flake.nix for home-manager to use";
|
||||
command =
|
||||
''
|
||||
[ -e "${homeFlake}" ] && echo "${homeFlake} already exists" && exit 1
|
||||
|
||||
mkdir -p "$(dirname "${homeFlake}")"
|
||||
ln -s "$(pwd)/flake.nix" "${homeFlake}"
|
||||
echo "Installed link to $(pwd)/flake.nix at ${homeFlake}"
|
||||
'';
|
||||
}
|
||||
{
|
||||
name = "home-unlink";
|
||||
category = "utilities";
|
||||
help = "Remove home-manager flake.nix link";
|
||||
command = "rm -f ${homeFlake}";
|
||||
}
|
||||
|
||||
{
|
||||
name = "fmt";
|
||||
category = "tasks";
|
||||
help = pkgs.nixpkgs-fmt.meta.description;
|
||||
command = ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@"'';
|
||||
}
|
||||
{
|
||||
name = "home-switch";
|
||||
category = "tasks";
|
||||
help = "Run `home-manager switch`";
|
||||
command = ''home-manager switch --flake . "$@"'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
3
util.nix
3
util.nix
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
let
|
||||
inherit (builtins) replaceStrings elemAt mapAttrs;
|
||||
inherit (lib) genAttrs mapAttrs' types mkOption mkOverride;
|
||||
inherit (lib) genAttrs mapAttrs' mapAttrsToList nameValuePair types mkOption mkOverride;
|
||||
inherit (lib.flake) defaultSystems;
|
||||
in
|
||||
rec {
|
||||
@ -20,6 +20,7 @@ rec {
|
||||
ip = checked (elemAt m 0);
|
||||
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
|
||||
};
|
||||
attrsToList = mapAttrsToList nameValuePair;
|
||||
|
||||
mkDefaultSystemsPkgs = path: args': genAttrs defaultSystems (system: import path ((args' system) // { inherit system; }));
|
||||
mkApp = program: { type = "app"; inherit program; };
|
||||
|
Loading…
Reference in New Issue
Block a user