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"
|
"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-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -59,6 +80,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"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": {
|
"locked": {
|
||||||
"lastModified": 1644229661,
|
"lastModified": 1644229661,
|
||||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||||
@ -208,7 +244,8 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"agenix": "agenix",
|
"agenix": "agenix",
|
||||||
"deploy-rs": "deploy-rs",
|
"deploy-rs": "deploy-rs",
|
||||||
"flake-utils": "flake-utils",
|
"devshell": "devshell",
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"impermanence": "impermanence",
|
"impermanence": "impermanence",
|
||||||
"nix": "nix",
|
"nix": "nix",
|
||||||
|
70
flake.nix
70
flake.nix
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
devshell.url = "github:numtide/devshell";
|
||||||
|
devshell.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||||
# Used by most systems
|
# Used by most systems
|
||||||
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
|
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
|
||||||
# For extra-stable systems
|
# For extra-stable systems
|
||||||
@ -35,7 +37,7 @@
|
|||||||
let
|
let
|
||||||
inherit (builtins) mapAttrs attrValues;
|
inherit (builtins) mapAttrs attrValues;
|
||||||
inherit (lib.flake) eachDefaultSystem;
|
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: {
|
extendLib = lib: lib.extend (final: prev: {
|
||||||
my = import ./util.nix { lib = final; };
|
my = import ./util.nix { lib = final; };
|
||||||
@ -54,6 +56,7 @@
|
|||||||
(_: path: mkDefaultSystemsPkgs path (system: {
|
(_: path: mkDefaultSystemsPkgs path (system: {
|
||||||
overlays = [
|
overlays = [
|
||||||
libOverlay
|
libOverlay
|
||||||
|
inputs.devshell.overlay
|
||||||
inputs.agenix.overlay
|
inputs.agenix.overlay
|
||||||
inputs.deploy-rs.overlay
|
inputs.deploy-rs.overlay
|
||||||
inputs.nix.overlay
|
inputs.nix.overlay
|
||||||
@ -115,36 +118,59 @@
|
|||||||
in
|
in
|
||||||
# Stuff for each platform
|
# Stuff for each platform
|
||||||
{
|
{
|
||||||
apps = {
|
devShell = pkgs.devshell.mkShell {
|
||||||
fmt = mkShellApp pkgs "fmt" ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@" .'';
|
env = attrsToList {
|
||||||
link = mkShellApp' pkgs {
|
# starship will show this
|
||||||
name = "install-home-link";
|
name = "devshell";
|
||||||
runtimeInputs = [ pkgs.coreutils ];
|
|
||||||
text =
|
NIX_USER_CONF_FILES = toString (pkgs.writeText "nix.conf"
|
||||||
''
|
''
|
||||||
[ -e "${homeFlake}" ] && echo "${homeFlake} already exists" && exit 1
|
experimental-features = nix-command flakes ca-derivations
|
||||||
|
'');
|
||||||
mkdir -p "$(dirname "${homeFlake}")"
|
|
||||||
ln -s "$(pwd)/flake.nix" "${homeFlake}"
|
|
||||||
echo "Installed link to $(pwd)/flake.nix at ${homeFlake}"
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
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; [
|
packages = with pkgs; [
|
||||||
|
coreutils
|
||||||
nix
|
nix
|
||||||
agenix
|
agenix
|
||||||
deploy-rs.deploy-rs
|
deploy-rs.deploy-rs
|
||||||
nixpkgs-fmt
|
|
||||||
home-manager
|
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 }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
inherit (builtins) replaceStrings elemAt mapAttrs;
|
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;
|
inherit (lib.flake) defaultSystems;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
@ -20,6 +20,7 @@ rec {
|
|||||||
ip = checked (elemAt m 0);
|
ip = checked (elemAt m 0);
|
||||||
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
|
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
|
||||||
};
|
};
|
||||||
|
attrsToList = mapAttrsToList nameValuePair;
|
||||||
|
|
||||||
mkDefaultSystemsPkgs = path: args': genAttrs defaultSystems (system: import path ((args' system) // { inherit system; }));
|
mkDefaultSystemsPkgs = path: args': genAttrs defaultSystems (system: import path ((args' system) // { inherit system; }));
|
||||||
mkApp = program: { type = "app"; inherit program; };
|
mkApp = program: { type = "app"; inherit program; };
|
||||||
|
Loading…
Reference in New Issue
Block a user