Add link and unlink apps
This commit is contained in:
parent
a30c45c01d
commit
0055f4c9b3
17
flake.nix
17
flake.nix
@ -35,7 +35,7 @@
|
||||
let
|
||||
inherit (builtins) mapAttrs attrValues;
|
||||
inherit (lib.flake) eachDefaultSystem;
|
||||
inherit (lib.my) mkApp mkShellApp inlineModules mkDefaultSystemsPkgs flakePackageOverlay;
|
||||
inherit (lib.my) mkApp mkShellApp mkShellApp' inlineModules mkDefaultSystemsPkgs flakePackageOverlay;
|
||||
|
||||
extendLib = lib: lib.extend (final: prev: {
|
||||
my = import ./util.nix { lib = final; };
|
||||
@ -108,6 +108,8 @@
|
||||
} //
|
||||
(eachDefaultSystem (system:
|
||||
let
|
||||
homeFlake = "$HOME/.config/nixpkgs/flake.nix";
|
||||
|
||||
pkgs = pkgs'.unstable.${system};
|
||||
lib = pkgs.lib;
|
||||
in
|
||||
@ -115,6 +117,19 @@
|
||||
{
|
||||
apps = {
|
||||
fmt = mkShellApp pkgs "fmt" ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@" .'';
|
||||
link = mkShellApp' pkgs {
|
||||
name = "install-home-link";
|
||||
runtimeInputs = [ pkgs.coreutils ];
|
||||
text =
|
||||
''
|
||||
[ -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}"
|
||||
'';
|
||||
};
|
||||
unlink = mkShellApp pkgs "remove-home-link" ''rm -f ${homeFlake}'';
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
|
@ -14,6 +14,10 @@ mkMerge [
|
||||
enable = true;
|
||||
settings = {};
|
||||
};
|
||||
|
||||
lsd = {
|
||||
enable = mkDefault true;
|
||||
};
|
||||
};
|
||||
|
||||
home = {
|
||||
|
4
util.nix
4
util.nix
@ -24,6 +24,10 @@ rec {
|
||||
mkDefaultSystemsPkgs = path: args': genAttrs defaultSystems (system: import path ((args' system) // { inherit system; }));
|
||||
mkApp = program: { type = "app"; inherit program; };
|
||||
mkShellApp = pkgs: name: text: mkApp (pkgs.writeShellScript name text).outPath;
|
||||
mkShellApp' = pkgs: args:
|
||||
let
|
||||
app = pkgs.writeShellApplication args;
|
||||
in mkApp "${app}/bin/${app.meta.mainProgram}";
|
||||
inlineModules = modules: mapAttrs
|
||||
(_: path:
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user