add devshell cli

This commit is contained in:
Tim Schubert 2022-10-28 17:00:34 +02:00
parent c781508dee
commit 771e718335
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA
4 changed files with 66 additions and 15 deletions

4
.envrc
View file

@ -1 +1,3 @@
use flake .#default
watch_file devshell.nix
use flake

View file

@ -1,11 +0,0 @@
{ self, pkgs, agenix, deploy-rs, system, ... }:
let
selfApp = app: self.apps."${app}";
in
pkgs.mkShell {
buildInputs = pkgs.lib.catAttrs system [
agenix.defaultPackage
deploy-rs.defaultPackage
(pkgs.lib.getAttrs [ "deploy" "update" "nixos-switch" ] self.apps)
];
}

50
devshell.nix Normal file
View file

@ -0,0 +1,50 @@
{ pkgs, ... }:
(pkgs.devshell.mkShell {
name = "dadada/nix-config";
packages = with pkgs; [
agenix
nixpkgs-fmt
nixos-rebuild
];
commands = [
{
name = "switch";
help = "Switch the configuration on the current system.";
command = ''
flake=$(nix flake metadata --json ${./.} | jq -r .url)
${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake ".#" --use-remote-sudo
'';
category = "deploy";
}
{
name = "format";
help = "Format the project";
command = ''
nixpkgs-fmt .
'';
category = "dev";
}
{
name = "update";
help = "Update the project";
command = ''
nix flake update --commit-lock-file
'';
category = "dev";
}
{
name = "deploy";
help = "Deploy this flake";
package = "deploy-rs";
category = "deploy";
}
{
name = "check";
help = "Run checks";
category = "dev";
command = "nix flake check";
}
];
})

View file

@ -11,6 +11,7 @@
, scripts
, recipemd
, agenix
, devshell
, ...
} @ inputs:
(flake-utils.lib.eachDefaultSystem (system:
@ -20,9 +21,18 @@
formatter = self.formatter.${system};
in
{
apps = import ./apps.nix (inputs // { inherit pkgs system; });
devShells.default = pkgs.callPackage ./dev-shell.nix inputs // { inherit pkgs system; };
devShells.default =
let
pkgs = import nixpkgs {
inherit system;
overlays = [
agenix.overlay
(final: prev: { deploy-rs = deploy-rs.defaultPackage.${system}; })
devshell.overlay
];
};
in
import ./devshell.nix { inherit pkgs; };
formatter = nixpkgs.legacyPackages."${system}".nixpkgs-fmt;