Merge pull request 'nixos-upgrade: Add extraCommands option' (#1) from extraCommands into main
Reviewed-on: #1
This commit is contained in:
commit
e1650a4b19
5 changed files with 76 additions and 58 deletions
|
@ -29,6 +29,8 @@ Adds a few new options to ``system.autoUpgrade``
|
|||
|
||||
``failureNotification`` sends a notification to a ntfy topic on an auto upgrade failure
|
||||
|
||||
``extraCommands`` extra commands to run during auto upgrade
|
||||
|
||||
```nix
|
||||
system.autoUpgrade = {
|
||||
enable = true;
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -3,18 +3,21 @@
|
|||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = {nixpkgs, ...}: let
|
||||
outputs = { nixpkgs, ... }:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
# Stolen from https://github.com/divnix/digga/blob/main/src/importers.nix
|
||||
rakeLeaves = dirPath: let
|
||||
rakeLeaves = dirPath:
|
||||
let
|
||||
seive = file: type:
|
||||
# Only rake `.nix` files or directories
|
||||
(type == "regular" && lib.hasSuffix ".nix" file) || (type == "directory");
|
||||
|
||||
collect = file: type: {
|
||||
name = lib.removeSuffix ".nix" file;
|
||||
value = let
|
||||
value =
|
||||
let
|
||||
path = dirPath + "/${file}";
|
||||
in
|
||||
if
|
||||
|
@ -28,7 +31,8 @@
|
|||
files = lib.filterAttrs seive (builtins.readDir dirPath);
|
||||
in
|
||||
lib.filterAttrs (n: v: v != { }) (lib.mapAttrs' collect files);
|
||||
in {
|
||||
in
|
||||
{
|
||||
nixosModules = rakeLeaves ./modules;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
cfg = config.system.autoUpgrade;
|
||||
|
||||
updateScript = pkgs.writeShellApplication {
|
||||
|
@ -15,26 +15,36 @@
|
|||
cd ${cfg.flake}
|
||||
git pull
|
||||
nix flake update --commit-lock-file
|
||||
${cfg.extraCommands}
|
||||
git push
|
||||
'';
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.system.autoUpgrade = {
|
||||
# TODO: make sure flake is a local folder
|
||||
# TODO: make sure system.autoUpgrade.flake is a local folder
|
||||
updateFlake = lib.mkOption {
|
||||
default = false;
|
||||
description = "Update lockfile of the flake.";
|
||||
example = true;
|
||||
};
|
||||
|
||||
extraCommands = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "Extra commands to run during upgrade";
|
||||
};
|
||||
|
||||
failureNotification = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
description = "Enable ntfy notification on upgrade failure.";
|
||||
example = true;
|
||||
};
|
||||
|
||||
ntfyUrlFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
description = "Environment file containing NTFY_URL";
|
||||
example = "/etc/secrets/failureNotification.env";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{ config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.qbittorrent-nox;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.services.qbittorrent-nox = {
|
||||
enable = lib.mkEnableOption "qbittorrent, BitTorrent client.";
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.unpackerr;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.services.unpackerr = {
|
||||
enable = lib.mkEnableOption "unpackerr";
|
||||
package = lib.mkPackageOption pkgs "unpackerr" { };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue