Added start- end end-scripts
This commit is contained in:
+54
-25
@@ -703,10 +703,26 @@ We also add a devshell that makes editing this repository easier in emacs.
|
|||||||
name = machine;
|
name = machine;
|
||||||
value = lib.nixosSystem {
|
value = lib.nixosSystem {
|
||||||
modules = [
|
modules = [
|
||||||
|
# Start_script.nix
|
||||||
|
({ lib, config, pkgs, ... }: {
|
||||||
|
imports = [ ./start_script.nix ];
|
||||||
|
})
|
||||||
<<flake-emacs-module>>
|
<<flake-emacs-module>>
|
||||||
<<flake-config-module>>
|
<<flake-config-module>>
|
||||||
<<flake-home-module>>
|
<<flake-home-module>>
|
||||||
catppuccin.nixosModules.catppuccin # theme
|
catppuccin.nixosModules.catppuccin # theme
|
||||||
|
|
||||||
|
# end_script as a systemd service
|
||||||
|
({ lib, config, pkgs, ... }: {
|
||||||
|
systemd.user.services.endScript = lib.mkIf (lib.fileExists ./assets/scripts/end_script.sh) {
|
||||||
|
description = "Run end script after Home Manager";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "home-manager-activate.service" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
${./assets/scripts/end_script.sh}
|
||||||
|
'';
|
||||||
|
};
|
||||||
];
|
];
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
@@ -894,6 +910,44 @@ This section describes the main system configuration for the computers that I ha
|
|||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** start_script.nix.nix
|
||||||
|
#+begin_src nix :tangle start_script.nix :noweb tangle :mkdirp yes
|
||||||
|
{ lib, config, pkgs, ... }:
|
||||||
|
let
|
||||||
|
scriptPath = ./assets/scripts/start_script.sh;
|
||||||
|
scriptExists = lib.fileExists "${scriptPath}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
system.activationScripts.startScript = lib.mkIf scriptExists {
|
||||||
|
text = ''
|
||||||
|
${scriptPath}
|
||||||
|
'';
|
||||||
|
defer = false; # Run as early as possible
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** end_script.nix.nix
|
||||||
|
#+begin_src nix :tangle end_script.nix :noweb tangle :mkdirp yes
|
||||||
|
{ lib, config, pkgs, ... }:
|
||||||
|
let
|
||||||
|
scriptPath = ./assets/scripts/end_script.sh;
|
||||||
|
scriptExists = lib.fileExists "${scriptPath}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
systemd.user.services.endScript = lib.mkIf scriptExists {
|
||||||
|
description = "Run end script after Home Manager";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "home-manager-activate.service" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
${scriptPath}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** Apps section
|
** Apps section
|
||||||
This section describes a way of installing packages, either through nixpkgs or flatpak.
|
This section describes a way of installing packages, either through nixpkgs or flatpak.
|
||||||
What extra apps to install is decided in the files ./assets/conf/apps/packages.conf and flatpaks.conf.
|
What extra apps to install is decided in the files ./assets/conf/apps/packages.conf and flatpaks.conf.
|
||||||
@@ -2904,31 +2958,6 @@ This is mostly about configuring the monitor. And laptop specific utilities.
|
|||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Copy Files 2 homefolder
|
|
||||||
This makes sure all ./assets/copy_stuff ends up in the right folder
|
|
||||||
#+begin_src nix :tangle home/copy_stuff.nix :noweb tangle :mkdirp yes.
|
|
||||||
{ config, pkgs, lib, flakeRoot, ... }:
|
|
||||||
{
|
|
||||||
home.activation.recreateConfig = {
|
|
||||||
text = ''
|
|
||||||
#!${pkgs.bash}/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
SOURCE_DIR="${flakeRoot}/assets/copy_stuff"
|
|
||||||
DEST_DIR="$HOME"
|
|
||||||
if [ ! -d "$SOURCE_DIR" ]; then
|
|
||||||
echo "Error: Source directory $SOURCE_DIR does not exist."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
mkdir -p "$DEST_DIR"
|
|
||||||
rsync -av --no-group --no-owner --delete "$SOURCE_DIR/" "$DEST_DIR/"
|
|
||||||
echo "Config files copied from $SOURCE_DIR to $DEST_DIR. Symlinks replaced with editable files."
|
|
||||||
hyprctl reload
|
|
||||||
'';
|
|
||||||
deps = [ pkgs.bash pkgs.rsync ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* README Utils
|
* README Utils
|
||||||
*** Headers
|
*** Headers
|
||||||
This script adds a =DO NOT MODIFY= header to all the generated nix files.
|
This script adds a =DO NOT MODIFY= header to all the generated nix files.
|
||||||
|
|||||||
+1
-3
@@ -8,10 +8,8 @@ if [ ! -d "$SOURCE_DIR" ]; then
|
|||||||
echo "Error: Source directory $SOURCE_DIR does not exist."
|
echo "Error: Source directory $SOURCE_DIR does not exist."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Create destination directory if it doesn't exist
|
|
||||||
mkdir -p "$DEST_DIR"
|
|
||||||
# Use rsync to copy files, overwriting symlinks and existing files
|
# Use rsync to copy files, overwriting symlinks and existing files
|
||||||
# --delete removes files in DEST_DIR that are not in SOURCE_DIR
|
# --delete removes files in DEST_DIR that are not in SOURCE_DIR
|
||||||
# --no-group --no-owner preserves your user ownership
|
# --no-group --no-owner preserves your user ownership
|
||||||
rsync -av --no-group --no-owner --delete "$SOURCE_DIR/" "$DEST_DIR/"
|
rsync -av --no-group --no-owner "$SOURCE_DIR/" "$DEST_DIR/"
|
||||||
echo "Config files copied from $SOURCE_DIR to $DEST_DIR. Symlinks replaced with editable files."
|
echo "Config files copied from $SOURCE_DIR to $DEST_DIR. Symlinks replaced with editable files."
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
# Example of how to execute a script
|
||||||
|
# Path to the script to execute
|
||||||
|
COPY_SCRIPT="./assets/scripts/copy_stuff.sh"
|
||||||
|
# Check if the script exists
|
||||||
|
if [ ! -f "$COPY_SCRIPT" ]; then
|
||||||
|
echo "Error: Script $COPY_SCRIPT does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Execute the script
|
||||||
|
"$COPY_SCRIPT"
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
# Example of how to execute a script
|
||||||
|
# Path to the script to execute
|
||||||
|
#COPY_SCRIPT="./assets/scripts/copy_stuff.sh"
|
||||||
|
# Check if the script exists
|
||||||
|
#if [ ! -f "$COPY_SCRIPT" ]; then
|
||||||
|
# echo "Error: Script $COPY_SCRIPT does not exist."
|
||||||
|
#$ exit 1
|
||||||
|
#fi
|
||||||
|
# Execute the script
|
||||||
|
#"$COPY_SCRIPT"
|
||||||
Reference in New Issue
Block a user