New service for end-script.sh
This commit is contained in:
+18
-10
@@ -858,7 +858,7 @@ I'll let the code comments explain the file here.
|
|||||||
This section describes the main system configuration for the computers that I have. Nix will look for a ~default.nix~ file if you give it a path to a folder to import. And ~default.nix~ looks as follows :-
|
This section describes the main system configuration for the computers that I have. Nix will look for a ~default.nix~ file if you give it a path to a folder to import. And ~default.nix~ looks as follows :-
|
||||||
|
|
||||||
#+begin_src nix :tangle configuration/default.nix :noweb tangle :mkdirp yes
|
#+begin_src nix :tangle configuration/default.nix :noweb tangle :mkdirp yes
|
||||||
{ pkgs, user, ... } :
|
{ pkgs, user, ... } :
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./apps/flatpaks.nix
|
./apps/flatpaks.nix
|
||||||
@@ -1459,21 +1459,29 @@ The configuration is done in the home manager section.
|
|||||||
|
|
||||||
** Setting the config
|
** Setting the config
|
||||||
#+begin_src nix :tangle configuration/end_script.nix :noweb tangle :mkdirp yes
|
#+begin_src nix :tangle configuration/end_script.nix :noweb tangle :mkdirp yes
|
||||||
{ config, pkgs, lib, ... }: {
|
{ lib, config, pkgs, ... }:
|
||||||
systemd.user.services.endScript = lib.mkIf (builtins.pathExists ./assets/scripts/end_script.sh) {
|
let
|
||||||
|
scriptPath = "${config.nixpkgs.config}/../assets/scripts/end_script.sh";
|
||||||
|
scriptExists = lib.fileExists "${scriptPath}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
systemd.user.services.endScript = lib.mkIf scriptExists {
|
||||||
description = "Run end script after Home Manager";
|
description = "Run end script after Home Manager";
|
||||||
wantedBy = [ "default.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "home-manager-henrov.service" ];
|
after = [ "home-manager-activate.service" ];
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
WorkingDirectory = "${config.nixpkgs.config}/..";
|
||||||
|
Environment = [
|
||||||
|
"HOME=${config.users.users.${config.users.mutableUsersList.[0].name}.home}"
|
||||||
|
];
|
||||||
|
};
|
||||||
script = ''
|
script = ''
|
||||||
${pkgs.bash}/bin/bash -c 'cd $HOME && ${./assets/scripts/end_script.sh}'
|
${scriptPath}
|
||||||
'';
|
'';
|
||||||
serviceConfig.Restart = "no";
|
|
||||||
enable = true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Services
|
** Services
|
||||||
|
|||||||
Reference in New Issue
Block a user