added some of my own scripts declaratively

Enabling systemd units and timers of my scripts
This commit is contained in:
Danilo Reyes 2023-05-10 19:35:08 -06:00
parent acab8b3089
commit 9a4e6ed758
2 changed files with 652 additions and 563 deletions

View File

@ -3,18 +3,18 @@ let
VERSION = "22.11";
# HOME-MANAGER = builtins.fetchTarball
# "https://github.com/nix-community/home-manager/archive/master.tar.gz";
UNSTABLE_TARBALL = builtins.fetchTarball
https://github.com/nixos/nixpkgs/tarball/master;
unstable = import UNSTABLE_TARBALL {
config = config.nixpkgs.config;
};
in
{ # Remember to close this bracket at the end of the document
UNSTABLE_TARBALL =
builtins.fetchTarball "https://github.com/nixos/nixpkgs/tarball/master";
unstable = import UNSTABLE_TARBALL { config = config.nixpkgs.config; };
nextcloud_scrapsync = pkgs.writeScriptBin "nextcloud_scrapsync"
(builtins.readFile ./scripts/nextcloud_scrapsync.sh);
manage_library = pkgs.writeScriptBin "manage_library"
(builtins.readFile ./scripts/manage_library.fish);
ffmpeg4discord = pkgs.writeScriptBin "ffmpeg4discord"
(builtins.readFile ./scripts/ffmpeg4discord.py);
in { # Remember to close this bracket at the end of the document
imports = [
./hardware-configuration.nix
<home-manager/nixos>
];
imports = [ ./hardware-configuration.nix <home-manager/nixos> ];
networking.hostName = "workstation";
@ -25,9 +25,7 @@ time.timeZone = "America/Mexico_City";
i18n = {
defaultLocale = "en_CA.UTF-8";
extraLocaleSettings = {
LC_MONETARY = "es_MX.UTF-8";
};
extraLocaleSettings = { LC_MONETARY = "es_MX.UTF-8"; };
};
console = {
font = "Lat2-Terminus16";
@ -56,8 +54,7 @@ environment.gnome.excludePackages = (with pkgs; [
gnome-connections
# gnome-shell-extensions
baobab
])
++ (with pkgs.gnome; [
]) ++ (with pkgs.gnome; [
# totem
gedit
gnome-music
@ -92,9 +89,7 @@ security.sudo = {
# noPass = true;
# }];
nixpkgs.config = {
allowUnfree = true;
};
nixpkgs.config = { allowUnfree = true; };
users.users.jawz = {
isNormalUser = true;
@ -182,6 +177,11 @@ xdg-ninja # help declutter $HOME
torrenttools # create torrent files from the terminal!
lm_sensors # for extension, displays cpu temp
# My own scripts
nextcloud_scrapsync
ffmpeg4discord
manage_library
# required by doom emacs, but still are rather useful.
fd # modern find, faster searches
fzf # fuzzy finder! super cool and useful
@ -237,12 +237,17 @@ gnome.gnome-tweaks # tweaks for the gnome desktop environment
# Fonts
(nerdfonts.override {
fonts = [ "Agave" "CascadiaCode" "SourceCodePro" "Ubuntu" "FiraCode" "Iosevka" ];
fonts = [
"Agave"
"CascadiaCode"
"SourceCodePro"
"Ubuntu"
"FiraCode"
"Iosevka"
];
})
symbola
(papirus-icon-theme.override {
color = "adwaita";
})
(papirus-icon-theme.override { color = "adwaita"; })
]) ++ (with pkgs.python310Packages; [
black # Python code formatter
@ -286,7 +291,8 @@ symbola
markdownlint-cli
prettier
pnpm
]); }; # <--- end of package list
]);
}; # <--- end of package list
fonts.fontconfig.enable = true;
@ -303,12 +309,15 @@ programs.fish = {
enable = true;
# useBabelfish = true; This setting doens't work from inside home-manager
shellAliases = {
ls = "exa --icons --group-directories-first --no-permissions --no-user --no-time";
ls =
"exa --icons --group-directories-first --no-permissions --no-user --no-time";
edit = "emacsclient -t";
comic = "download -u jawz -i (cat $lc | fzf --multi --exact -i)";
gallery = "download -u jawz -i (cat $lw | fzf --multi --exact -i)";
open_gallery = "open (find /mnt/disk2/scrapping/JawZ/gallery-dl -type d | fzf)";
unique_extensions = "find . -type f | string match -r '([^.\/]+)\$' | sort -u";
open_gallery =
"open (find /mnt/disk2/scrapping/JawZ/gallery-dl -type d | fzf)";
unique_extensions =
"find . -type f | string match -r '([^./]+)$' | sort -u";
cp = "cp -i";
mv = "mv -i";
mkdir = "mkdir -p";
@ -375,7 +384,8 @@ programs = {
config = {
# map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ];
pager = "less -FR";
theme = "base16"; };
theme = "base16";
};
};
git = {
enable = true;
@ -408,7 +418,8 @@ xdg = {
};
configFile = {
"wgetrc".source = ./dotfiles/wget/wgetrc;
"configstore/update-notifier-npm-check.json".source = ./dotfiles/npm/update-notifier-npm-check.json;
"configstore/update-notifier-npm-check.json".source =
./dotfiles/npm/update-notifier-npm-check.json;
"npm/npmrc".source = ./dotfiles/npm/npmrc;
"gallery-dl/config.json".source = ./dotfiles/gallery-dl/config.json;
"htop/htoprc".source = ./dotfiles/htop/htoprc;
@ -494,9 +505,7 @@ snapraid = {
olderThan = 10;
interval = "4:00";
};
parityFiles = [
"/mnt/parity/snapraid.parity"
];
parityFiles = [ "/mnt/parity/snapraid.parity" ];
extraConfig = ''
autosave 50
'';
@ -528,9 +537,7 @@ programs = {
enable = true;
enableSSHSupport = true;
};
geary = {
enable = true;
};
geary = { enable = true; };
steam = {
enable = true;
remotePlay.openFirewall = true;
@ -549,11 +556,7 @@ services = {
fstrim.enable = true;
btrfs.autoScrub = {
enable = true;
fileSystems = [
"/"
"/mnt/disk1"
"/mnt/disk2"
];
fileSystems = [ "/" "/mnt/disk1" "/mnt/disk2" ];
};
openssh = {
enable = true;
@ -578,17 +581,42 @@ systemd.services = {
environment = {
FILE = "/home/jawz/Development/Docker/docker-compose.yml";
};
path = [
pkgs.docker-compose
];
path = [ pkgs.docker-compose ];
serviceConfig = {
Restart = "on-failure";
# Type = "simple";
RestartSec = 30;
ExecStart = "${pkgs.docker-compose}/bin/docker-compose -f \${FILE} up --remove-orphans";
ExecStart =
"${pkgs.docker-compose}/bin/docker-compose -f \${FILE} up --remove-orphans";
ExecStop = "${pkgs.docker-compose}/bin/docker-compose -f \${FILE} down";
};
};
"nextcloud_scrapsync" = {
description = "Sync scrapped files with nextcloud";
wantedBy = [ "default.target" ];
path = [ pkgs.bash nextcloud_scrapsync ];
serviceConfig = {
RestartSec = 30;
ExecStart = "${nextcloud_scrapsync}/bin/nextcloud_scrapsync";
};
};
};
systemd.timers = {
"nextcloud_scrapsync" = {
enable = true;
description = "Sync scrapped files with nextcloud";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = [
"*-*-* 01:32:00"
"*-*-* 08:32:00"
"*-*-* 14:32:00"
"*-*-* 20:32:00"
];
RandomizedDelaySec = 30;
Persistent = true;
};
};
};
systemd.user.services = {
"HentaiAtHome" = {
@ -596,9 +624,7 @@ systemd.user.services = {
restartIfChanged = true;
description = "Run hentai@home server";
wantedBy = [ "default.target" ];
path = [
pkgs.HentaiAtHome
];
path = [ pkgs.HentaiAtHome ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
@ -606,6 +632,18 @@ systemd.user.services = {
ExecStart = "${pkgs.HentaiAtHome}/bin/HentaiAtHome";
};
};
"manage_library" = {
enable = true;
restartIfChanged = true;
description = "Run the manage library fish script";
wantedBy = [ "default.target" ];
path = [ pkgs.fish manage_library ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${manage_library}/bin/manage_library";
};
};
};
# networking.firewall.allowedTCPPorts = [ ... ];
@ -615,7 +653,7 @@ networking.firewall.enable = false;
system.copySystemConfiguration = true;
nix.gc = {
enable = true;
automatic = true;
dates = "weekly";
};

View File

@ -11,11 +11,6 @@
- [ ] Automatic updates
- [ ] Firewall ports
- [ ] Topgrade (perhaps unnecessary)
- [ ] SystemD services [4/5]
- [ ] Personal scripts [0/3]
- [ ] download
- [ ] Instagram
- [ ] startup tasks
- [ ] dotfiles [0/4]
- [ ] create a declarative Firefox or Librewolf install
- [ ] migrate config to home-manager
@ -53,6 +48,12 @@ let
unstable = import UNSTABLE_TARBALL {
config = config.nixpkgs.config;
};
nextcloud_scrapsync = pkgs.writeScriptBin
"nextcloud_scrapsync" (builtins.readFile ./scripts/nextcloud_scrapsync.sh);
manage_library = pkgs.writeScriptBin
"manage_library" (builtins.readFile ./scripts/manage_library.fish);
ffmpeg4discord = pkgs.writeScriptBin
"ffmpeg4discord" (builtins.readFile ./scripts/ffmpeg4discord.py);
in
{ # Remember to close this bracket at the end of the document
#+end_src
@ -358,6 +359,12 @@ tree-sitter # code parsing, required by Doom emacs
xdg-ninja # help declutter $HOME
torrenttools # create torrent files from the terminal!
lm_sensors # for extension, displays cpu temp
# My own scripts
nextcloud_scrapsync
ffmpeg4discord
manage_library
#+end_src
** DEVELOPMENT PACKAGES
@ -894,6 +901,35 @@ systemd.services = {
ExecStop = "${pkgs.docker-compose}/bin/docker-compose -f \${FILE} down";
};
};
"nextcloud_scrapsync" = {
description = "Sync scrapped files with nextcloud";
wantedBy = [ "default.target" ];
path = [
pkgs.bash
nextcloud_scrapsync
];
serviceConfig = {
RestartSec = 30;
ExecStart = "${nextcloud_scrapsync}/bin/nextcloud_scrapsync";
};
};
};
systemd.timers = {
"nextcloud_scrapsync" = {
enable = true;
description = "Sync scrapped files with nextcloud";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar= [
"*-*-* 01:32:00"
"*-*-* 08:32:00"
"*-*-* 14:32:00"
"*-*-* 20:32:00"
];
RandomizedDelaySec = 30;
Persistent = true;
};
};
};
systemd.user.services = {
"HentaiAtHome" = {
@ -911,6 +947,21 @@ systemd.user.services = {
ExecStart = "${pkgs.HentaiAtHome}/bin/HentaiAtHome";
};
};
"manage_library" = {
enable = true;
restartIfChanged = true;
description = "Run the manage library fish script";
wantedBy = [ "default.target" ];
path = [
pkgs.fish
manage_library
];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${manage_library}/bin/manage_library";
};
};
};
#+end_src
@ -934,7 +985,7 @@ accidentally delete configuration.nix.
#+begin_src nix
system.copySystemConfiguration = true;
nix.gc = {
enable = true;
automatic = true;
dates = "weekly";
};
#+end_src