diff --git a/configs/default.nix b/configs/default.nix index b4fd5fc..86dd3ff 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -3,6 +3,7 @@ lib, config, niveumPackages, + inputs, ... }: let inherit (lib.strings) makeBinPath; @@ -10,16 +11,12 @@ defaultApplications = (import ../lib).defaultApplications {inherit pkgs;}; in { imports = [ - ../modules/system-dependent.nix + inputs.self.nixosModules.system-dependent + inputs.self.nixosModules.traadfri + inputs.self.nixosModules.power-action { boot.supportedFilesystems = ["ntfs"]; } - { - nix.nixPath = [ - "/var/src" - "nixpkgs-overlays=${toString ../overlays}" - ]; - } { nixpkgs = { config = { diff --git a/configs/hledger.nix b/configs/hledger.nix index 42d8261..36fe441 100644 --- a/configs/hledger.nix +++ b/configs/hledger.nix @@ -3,10 +3,10 @@ pkgs, ... }: { - imports = [../modules/hledger.nix]; - environment.systemPackages = let - timeLedger = "$HOME/projects/ledger/time.timeclock"; + ledgerDirectory = "$HOME/projects/ledger"; + timeLedger = "${ledgerDirectory}/time.timeclock"; + git = "${pkgs.git}/bin/git -C ${ledgerDirectory}"; in [ (pkgs.writers.writeDashBin "hora-edit" '' $EDITOR + "${timeLedger}" && ${pkgs.git}/bin/git -C "$(${pkgs.coreutils}/bin/dirname ${timeLedger})" commit --all --message "$(${pkgs.coreutils}/bin/date -Im)" @@ -21,16 +21,18 @@ | sed 's/(fillidefilla:\(.*\))/\1/g' \ | xsv select date,amount,total,account,description '') - ]; - niveum.hledger = { - enable = true; - ledgerFile = "$HOME/projects/ledger/all.journal"; - server = { - enable = false; - user = config.users.users.me; - package = pkgs.hledger-web; - }; - package = pkgs.hledger; - }; + (pkgs.writers.writeDashBin "hledger-git" '' + if [ "$1" = entry ]; then + ${pkgs.hledger}/bin/hledger balance -V > "${ledgerDirectory}/balance.txt" + ${git} add balance.txt + ${git} commit --all --message="$(date -Im)" + else + ${git} $* + fi + '') + (pkgs.writers.writeDashBin "hledger-edit" '' + $EDITOR ${ledgerDirectory}/current.journal + '') + ]; } diff --git a/configs/networkmanager.nix b/configs/networkmanager.nix index 7ba8e5d..a337b3e 100644 --- a/configs/networkmanager.nix +++ b/configs/networkmanager.nix @@ -42,8 +42,6 @@ }; }; in { - imports = [../modules/networkmanager-declarative.nix]; - programs.nm-applet.enable = true; networking.networkmanager = { diff --git a/configs/power-action.nix b/configs/power-action.nix index 593e7c3..b466908 100644 --- a/configs/power-action.nix +++ b/configs/power-action.nix @@ -5,8 +5,6 @@ }: let suspend = pkgs.writers.writeDash "suspend" "${pkgs.systemd}/bin/systemctl suspend"; in { - imports = [../modules/power-action.nix]; - services.power-action = { enable = true; plans.suspend = { diff --git a/configs/telegram-bots/default.nix b/configs/telegram-bots/default.nix index 6f15ae7..3521eb4 100644 --- a/configs/telegram-bots/default.nix +++ b/configs/telegram-bots/default.nix @@ -19,7 +19,6 @@ in { ./nachtischsatan.nix ./tlg-wotd.nix ./celan.nix - ../../modules/telegram-bot.nix ]; systemd.tmpfiles.rules = map (path: diff --git a/configs/traadfri.nix b/configs/traadfri.nix index a2fc460..6d283f6 100644 --- a/configs/traadfri.nix +++ b/configs/traadfri.nix @@ -7,8 +7,6 @@ inherit (import ../lib) localAddresses; living-room-id = 131090; in { - imports = [../modules/traadfri.nix]; - environment.systemPackages = [ (pkgs.writers.writeDashBin "traadfri-party" '' while true; do diff --git a/flake.nix b/flake.nix index 8260e06..7e9f141 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,17 @@ { apps = nixinate.nixinate.x86_64-linux self; + nixosModules = { + htgen = import modules/htgen.nix; + moodle-dl = import modules/moodle-dl.nix; + networkmanager-declarative = import modules/networkmanager-declarative.nix; + passport = import modules/passport.nix; + power-action = import modules/power-action.nix; + system-dependent = import modules/system-dependent.nix; + telegram-bot = import modules/telegram-bot.nix; + traadfri = import modules/traadfri.nix; + }; + nixosConfigurations = { ful = nixpkgs.lib.nixosSystem rec { system = "aarch64-linux"; @@ -85,6 +96,7 @@ }; } systems/zaatar/configuration.nix + inputs.self.nixosModules.moodle-dl agenix.nixosModules.default retiolum.nixosModules.retiolum ]; @@ -107,6 +119,9 @@ }; } systems/makanek/configuration.nix + inputs.self.nixosModules.telegram-bot + inputs.self.nixosModules.htgen + inputs.self.nixosModules.passport agenix.nixosModules.default retiolum.nixosModules.retiolum nur.nixosModules.nur diff --git a/modules/dropbox.nix b/modules/dropbox.nix deleted file mode 100644 index 37c55ca..0000000 --- a/modules/dropbox.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -with lib; let - cfg = config.niveum.dropbox; -in { - options.niveum.dropbox = {enable = mkEnableOption "Dropbox";}; - - config = mkIf cfg.enable { - environment.systemPackages = [pkgs.dropbox-cli]; - - networking.firewall = { - allowedTCPPorts = [17500]; - allowedUDPPorts = [17500]; - }; - - systemd.user.services.dropbox = { - description = "Dropbox synchronisation service"; - wantedBy = ["graphical-session.target"]; - serviceConfig = { - ExecStart = "${pkgs.dropbox.out}/bin/dropbox"; - ExecReload = "${pkgs.coreutils.out}/bin/kill -HUP $MAINPID"; - KillMode = "control-group"; # upstream recommends process - Restart = "on-failure"; - PrivateTmp = true; - ProtectSystem = "full"; - Nice = 10; - }; - }; - }; -} diff --git a/modules/hledger.nix b/modules/hledger.nix deleted file mode 100644 index a905c7d..0000000 --- a/modules/hledger.nix +++ /dev/null @@ -1,86 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.niveum.hledger; - hledger-git = pkgs.writers.writeDashBin "hledger-git" '' - LEDGER_DIR="$(dirname $LEDGER_FILE)" - GIT="${pkgs.git}/bin/git -C ''${LEDGER_DIR}" - if [ "$1" = entry ]; then - ${cfg.package}/bin/hledger balance -V > "$LEDGER_DIR/balance.txt" - $GIT add balance.txt - $GIT commit --all --message="$(date -Im)" - else - $GIT $* - fi - ''; - hledger-edit = pkgs.writers.writeDashBin "hledger-edit" '' - LEDGER_DIR="$(dirname $LEDGER_FILE)" - $EDITOR ''${LEDGER_DIR}/current.journal - ''; -in { - options.niveum.hledger = { - enable = mkEnableOption "hledger"; - package = mkOption { - type = types.package; - default = pkgs.hledger; - }; - ledgerFile = mkOption { - type = types.str; - default = null; - }; - server = { - enable = mkEnableOption "hledger server"; - port = mkOption { - type = types.port; - default = 5000; - }; - host = mkOption { - type = types.str; - default = "127.0.0.1"; - }; - capabilities = mkOption { - type = types.listOf (types.enum ["view" "add" "manage"]); - default = ["view" "add"]; - }; - flags = mkOption { - type = types.listOf types.str; - default = []; - }; - user = mkOption {type = types.attrs;}; - package = mkOption { - type = types.package; - default = pkgs.hledger-web; - }; - }; - }; - - config = mkIf cfg.enable { - environment.systemPackages = [cfg.package hledger-git hledger-edit]; - - environment.variables.LEDGER_FILE = - mkIf (cfg.ledgerFile != null) cfg.ledgerFile; - - systemd.services.hledger-web = mkIf cfg.server.enable { - description = "hledger server"; - wantedBy = ["multi-user.target"]; - serviceConfig = { - Restart = "always"; - ExecStart = '' - ${cfg.server.package}/bin/hledger-web \ - --port=${toString cfg.server.port} \ - --host=${cfg.server.host} \ - --capabilities=${concatStringsSep "," cfg.server.capabilities} \ - ${concatStringsSep " " cfg.server.flags} - ''; - User = cfg.server.user.name; - PrivateTemp = true; - RuntimeDirectory = "hledger-web"; - WorkingDirectory = "%t/hledger-web"; - }; - }; - }; -} diff --git a/modules/minecraft.nix b/modules/minecraft.nix deleted file mode 100644 index 5bb5cca..0000000 --- a/modules/minecraft.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -with lib; let - cfg = config.niveum.minecraft; -in { - options.niveum.minecraft = {enable = mkEnableOption "Minecraft";}; - - config = mkIf cfg.enable {environment.systemPackages = [pkgs.minecraft];}; -} diff --git a/modules/spotifyd.nix b/modules/spotifyd.nix deleted file mode 100644 index aa92365..0000000 --- a/modules/spotifyd.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.services.spotifyd; - toml = pkgs.formats.toml {}; - spotifydConf = - if cfg.settings != {} - then toml.generate "spotify.conf" cfg.settings - else pkgs.writeText "spotifyd.conf" cfg.config; -in { - options = { - services.spotifyd = { - enable = mkEnableOption "spotifyd, a Spotify playing daemon"; - - config = mkOption { - default = ""; - type = types.lines; - description = '' - (Deprecated) Configuration for Spotifyd. For syntax and directives, see - . - ''; - }; - - settings = mkOption { - default = {}; - type = toml.type; - description = '' - Configuration for Spotifyd. For syntax and directives, see - . - ''; - }; - }; - }; - - config = mkIf cfg.enable { - assertions = [ - { - assertion = (cfg.config == "" && cfg.settings != {}) || (cfg.config != "" && cfg.settings == {}); - message = "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead."; - } - ]; - - systemd.services.spotifyd = { - wantedBy = ["multi-user.target"]; - after = ["network-online.target" "sound.target"]; - description = "spotifyd, a Spotify playing daemon"; - environment.SHELL = "/bin/sh"; - serviceConfig = { - ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache-path /var/cache/spotifyd --config-path ${spotifydConf}"; - Restart = "always"; - RestartSec = 12; - DynamicUser = true; - CacheDirectory = "spotifyd"; - SupplementaryGroups = ["audio"]; - }; - }; - }; - - meta.maintainers = [maintainers.anderslundstedt]; -} diff --git a/modules/tuna.nix b/modules/tuna.nix deleted file mode 100644 index 2c05a46..0000000 --- a/modules/tuna.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - tuna = pkgs.callPackage {}; - cfg = config.services.tuna; -in { - imports = []; - - options.services.tuna = { - enable = mkEnableOption "Tuna, an MPD web UI for radio streams"; - - webPort = mkOption { - type = types.port; - default = 4200; - }; - - stations = mkOption { - default = []; - type = types.listOf (types.submodule { - options = { - id = mkOption { - type = types.int; - description = "A unique identifier of the station"; - }; - station = mkOption { - type = types.str; - description = "Name of the station that should be displayed"; - }; - desc = mkOption { - type = types.nullOr types.str; - description = "Short description of the station (optional)"; - }; - logo = mkOption { - type = types.str; - description = "URL to a logo of the station (any size)"; - }; - stream = mkOption { - type = types.str; - description = "URL to the stream of the radio station (in a format supported by MPD such as MP3, OGG, ...)"; - }; - }; - }); - }; - - stationsFile = mkOption { - type = types.path; - default = (pkgs.formats.json {}).generate "stations.json" cfg.stations; - }; - - package = mkOption { - type = types.package; - default = tuna; - }; - - mpd = { - host = mkOption { - type = types.str; - default = "localhost"; - description = "The host where MPD is listening."; - example = "localhost"; - }; - - port = mkOption { - type = types.port; - default = config.services.mpd.network.port; - description = "The port where MPD is listening."; - example = 6600; - }; - }; - }; - - config = mkIf cfg.enable { - users.users.tuna = { - isSystemUser = true; - group = "tuna"; - }; - users.groups.tuna = {}; - # ref https://github.com/florianheinemann/MPD.FM/blob/9d037cf87597b26ae2f10ba9feea48946ad6cc68/service/MPD.FM.service - systemd.services.tuna = { - wantedBy = ["multi-user.target"]; - after = ["mpd.service"]; - script = "${cfg.package}/bin/tuna"; - environment = { - NODE_ENV = "production"; - MPD_HOST = cfg.mpd.host; - MPD_PORT = toString cfg.mpd.port; - PORT = toString cfg.webPort; - STATION_FILE = cfg.stationsFile; - }; - serviceConfig = { - Restart = "always"; - StandardOutput = "syslog"; - StandardError = "syslog"; - SyslogIdentifier = "tuna"; - User = "tuna"; - }; - }; - }; -} diff --git a/overlays/overlays.nix b/overlays/overlays.nix deleted file mode 100644 index 97ac9ed..0000000 --- a/overlays/overlays.nix +++ /dev/null @@ -1,6 +0,0 @@ -self: super: -with super.lib; let - eval = import ; - paths = (eval {modules = [(import )];}).config.nixpkgs.overlays; -in - foldl' (flip extends) (_: super) paths self diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index eee1de4..b324469 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -29,7 +29,6 @@ in { ../../configs/spacetime.nix ../../configs/sshd.nix ../../configs/telegram-bots - ../../modules/passport.nix ]; services.restic.backups.niveum = { diff --git a/systems/makanek/moodle-dl-borsfaye.nix b/systems/makanek/moodle-dl-borsfaye.nix deleted file mode 100644 index abbd551..0000000 --- a/systems/makanek/moodle-dl-borsfaye.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: let - moodle-dl-package = pkgs.moodle-dl.overrideAttrs (old: - old - // { - patches = []; - }); -in { - imports = []; - - niveum.passport.services = [ - { - title = "MoodleDL"; - description = "notifies about changes on Moodle."; - } - ]; - - services.moodle-dl = { - enable = true; - startAt = "hourly"; - package = moodle-dl-package; - notifyOnly = true; - settings = { - telegram = { - token = lib.strings.fileContents ; - chat_id = "311425510"; - send_error_msg = false; - }; - token = lib.strings.fileContents ; - moodle_domain = "moodle.hu-berlin.de"; - moodle_path = "/"; - }; - }; -} diff --git a/systems/makanek/tarot.nix b/systems/makanek/tarot.nix index 5ce8fce..d633310 100644 --- a/systems/makanek/tarot.nix +++ b/systems/makanek/tarot.nix @@ -15,8 +15,6 @@ sha256 = "1n2m53kjg2vj9dbr70b9jrsbqwdfrcb48l4wswn21549fi24g6dx"; }; in { - imports = [../../modules/htgen.nix]; - services.htgen.tarot = { port = tarotPort; script = ''. ${pkgs.writers.writeDash "tarot" '' diff --git a/systems/zaatar/configuration.nix b/systems/zaatar/configuration.nix index 3ffb7d8..a0269b5 100644 --- a/systems/zaatar/configuration.nix +++ b/systems/zaatar/configuration.nix @@ -50,8 +50,6 @@ in { ]; }; - nix.nixPath = ["/var/src"]; - services.logind = { lidSwitch = "ignore"; lidSwitchDocked = "ignore"; diff --git a/systems/zaatar/moodle-dl-meinhark.nix b/systems/zaatar/moodle-dl-meinhark.nix index b5a4e74..0294565 100644 --- a/systems/zaatar/moodle-dl-meinhark.nix +++ b/systems/zaatar/moodle-dl-meinhark.nix @@ -10,8 +10,6 @@ patches = [../../packages/moodle-dl/telegram-format.patch]; }); in { - imports = [../../modules/moodle-dl.nix]; - age.secrets = { moodle-dl-tokens = { file = ../../secrets/zaatar-moodle-dl-tokens.json.age;