diff --git a/configuration.nix b/configuration.nix index 523da4c..49a161f 100644 --- a/configuration.nix +++ b/configuration.nix @@ -14,10 +14,10 @@ ./programs/installed.nix ./services/enabled.nix ./users.nix - ./desktop.nix + ./desktop.nix ./setup.nix ]; - + nixpkgs.config.allowUnfree = true; nix.gc.automatic = true; nix.gc.dates = "03:15"; @@ -27,7 +27,7 @@ # servers. You should change this only after NixOS release notes say you # should. system = { - stateVersion = "17.09"; # Did you read the comment? + stateVersion = "18.03"; # Did you read the comment? autoUpgrade.enable = true; }; } diff --git a/desktop.nix b/desktop.nix index c617e15..5e06375 100644 --- a/desktop.nix +++ b/desktop.nix @@ -1,16 +1,16 @@ { config, pkgs, ... }: { - services.xserver.enable = true; + services.xserver.enable = false; services.xserver.displayManager.lightdm = { - enable = true; + enable = false; autoLogin = { enable = true; user = "devel"; }; }; services.xserver.desktopManager = { - xfce.enable = true; - default = "xfce"; + xfce.enable = false; + default = "none"; }; } diff --git a/module/news2kindle2/calibre-disable_plugins.patch b/module/news2kindle2/calibre-disable_plugins.patch new file mode 100644 index 0000000..9ef1dd0 --- /dev/null +++ b/module/news2kindle2/calibre-disable_plugins.patch @@ -0,0 +1,17 @@ +Description: Disable plugin dialog. It uses a totally non-authenticated and non-trusted way of installing arbitrary code. +Author: Martin Pitt +Bug-Debian: http://bugs.debian.org/640026 + +Index: calibre-0.8.29+dfsg/src/calibre/gui2/actions/preferences.py +=================================================================== +--- calibre-0.8.29+dfsg.orig/src/calibre/gui2/actions/preferences.py 2011-12-16 05:49:14.000000000 +0100 ++++ calibre-0.8.29+dfsg/src/calibre/gui2/actions/preferences.py 2011-12-20 19:29:04.798468930 +0100 +@@ -28,8 +28,6 @@ + pm.addAction(QIcon(I('config.png')), _('Preferences'), self.do_config) + cm('welcome wizard', _('Run welcome wizard'), + icon='wizard.png', triggered=self.gui.run_wizard) +- cm('plugin updater', _('Get plugins to enhance calibre'), +- icon='plugins/plugin_updater.png', triggered=self.get_plugins) + if not DEBUG: + pm.addSeparator() + cm('restart', _('Restart in debug mode'), icon='debug.png', diff --git a/module/news2kindle2/cronjob-options.nix b/module/news2kindle2/cronjob-options.nix new file mode 100644 index 0000000..e81f379 --- /dev/null +++ b/module/news2kindle2/cronjob-options.nix @@ -0,0 +1,17 @@ +{ config, lib }: + +with lib; +{ + options = { + cronExpression = mkOption { + type = types.str; + default = "0 5 * * *"; + description = '' cron expression, when fetch should started. ''; + example = "0 5 * * *"; + }; + + recipes = mkOption { + type = types.listOf (types.submodule (import ./recipe-options.nix { inherit config lib; })); + }; + }; +} diff --git a/module/news2kindle2/news2kindle.nix b/module/news2kindle2/news2kindle.nix new file mode 100644 index 0000000..bf43c4c --- /dev/null +++ b/module/news2kindle2/news2kindle.nix @@ -0,0 +1,170 @@ +{ config, lib, pkgs, fetchurl, ... }: + +with lib; + +let + + cfg = config.services.news2kindle; + +portString = toString cfg.smtp.port; + + convertScript = pkgs.writeText "convertScript.sh" ''#!/bin/bash +NAME=$1 +RECIPEPATH=$2 +MOBIPATH=$3 +FROMADDR=$4 +TOADDR=$5 +if [ ! -f mobi/$NAME.mobi ]; then + ebook-convert $RECIPEPATH/$NAME.recipe $MOBIPATH/$NAME.mobi --output-profile kindle -v +fi + +mailsend -smtp ${cfg.smtp.address} -port ${portString} -from $FROMADDR -to $TOADDR -sub "New news from $NAME" -attach $MOBIPATH/$NAME.mobi +sleep 60 +''; + +reps = mapAttrsToList (name: value: + let + mailAddress = if value.mailAddress != null + then value.mailAddress + else name; + cronJobs = mapAttrsToList ( jobExpr: jobValue: + let + cronExpression = if jobValue.cronExpression != "0 5 * * *" + then jobValue.cronExpression + else jobExpr; + in + jobValue // {cronExpression = cronExpression;}) value.cronJobs; + in + value // { mailAddress = name; cronJobs = cronJobs; } +) cfg.recipients; + +jobs = concatMap(recipient: concatMap(cronjob: + let + scriptName = builtins.replaceStrings ["*"] ["star"] (builtins.replaceStrings [" "] ["_"] (builtins.replaceStrings ["@"] [""] "${recipient.mailAddress}-${cronjob.cronExpression}.sh")); + scriptlines = concatMapStrings(recipe: + if isNull recipe.content then + "bash ${convertScript} ${recipe.name} ${calibreWithRecipes}/var/news2kindle/recipes ${cfg.mobiPath} ${recipient.fromMail} ${recipient.mailAddress}\n" + else + '' + mkdir -p /tmp/news2kindle/recipes + echo "${recipe.content}" > /tmp/news2kindle/recipes/${recipe.name}.recipe + bash ${convertScript} ${recipe.name} /tmp/news2kindle/recipes/ ${cfg.mobiPath} ${recipient.fromMail} ${recipient.mailAddress} + '' ) cronjob.recipes; + script = pkgs.writeText "${scriptName}" ''#!/bin/bash + rm -f ${cfg.mobiPath}/*.mobi + mkdir -p ${cfg.mobiPath} + ${scriptlines} + ''; + in + ["${cronjob.cronExpression} root bash ${script}"]) recipient.cronJobs) reps; + + +odfpyNoTest = pkgs.python2Packages.odfpy.overrideAttrs (oldAttrs: rec { + doInstallCheck = false; +}); + + + +calibreWithRecipes = pkgs.calibre.overrideAttrs (oldAttrs: rec { + installPhase = '' + mkdir -p $out/var/news2kindle/recipes + cp -ravf recipes $out/var/news2kindle + ''+ oldAttrs.installPhase ; + + buildInputs = (remove pkgs.python2Packages.odfpy oldAttrs.buildInputs) ++ [odfpyNoTest]; + +# patches = oldAttrs.patches ++ [./calibre-disable_plugins.patch]; + patches = [./calibre-disable_plugins.patch]; + +}); + + +in + +{ + ###### interface + + options = { + + services.news2kindle = { + + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable news2kindle service. + ''; + }; + + recipePath = mkOption { + example = "/var/news2kindle/recipes"; + default = "/var/news2kindle/recipes"; + type = types.str; + description = '' + Path where the recipes should be saved + ''; + }; + + mobiPath = mkOption { + example = "/tmp/news2kindle/mobi"; + default = "/tmp/news2kindle/mobi"; + type = types.str; + description = '' + Path where the mobi files should be saved + ''; + }; + + fromMail = mkOption { + example = "news@stubbe.rocks"; + default = "news@stubbe.rocks"; + type = types.str; + description = '' + Adrees of the sender, please allow this mail in your kindle doc service + ''; + }; + + + recipients = mkOption { + type = types.attrsOf (types.submodule (import ./recipient-options.nix { inherit config lib; })); + }; + + smtp = { + + address = mkOption { + type = types.str; + default = "localhost"; + description = "Address of the SMTP server for news2kindle."; + }; + + port = mkOption { + type = types.int; + default = 25; + description = "Port of the SMTP server for news2kindle."; + }; + + username = mkOption { + type = types.nullOr types.str; + default = null; + description = "Username of the SMTP server for news2kindle."; + }; + + password = mkOption { + type = types.nullOr types.str; + default = null; + description = "Password of the SMTP server for news2kindle."; + }; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable{ + environment.systemPackages = [pkgs.python27Packages.pyqt5 pkgs.python36Packages.pyqt5 pkgs.mailsend calibreWithRecipes]; + services.cron.enable = true; + services.cron.systemCronJobs = jobs; + }; +} diff --git a/module/news2kindle2/recipe-options.nix b/module/news2kindle2/recipe-options.nix new file mode 100644 index 0000000..93e8d6f --- /dev/null +++ b/module/news2kindle2/recipe-options.nix @@ -0,0 +1,17 @@ +{ config, lib }: + +with lib; +{ + options = { + name = mkOption { + type = types.str; + default = null; + description = '' name of recipe ''; + }; + content = mkOption { + type = types.nullOr types.str; + default = null; + description = '' content of the recipe file, when its null the use the builtins recipes ''; + }; + }; +} diff --git a/module/news2kindle2/recipient-options.nix b/module/news2kindle2/recipient-options.nix new file mode 100644 index 0000000..19b0f36 --- /dev/null +++ b/module/news2kindle2/recipient-options.nix @@ -0,0 +1,30 @@ +{ config, lib }: + +let + cfg = config.services.news2kindle; +in + +with lib; +{ + options = { + mailAddress = mkOption { + type = types.str; + default = null; + description = '' mail address of the recipient ''; + example = "foo@bar.bla"; + }; + + fromMail = mkOption { + example = "foo@bar.bla"; + default = cfg.fromMail; + type = types.str; + description = '' + Adrees of the sender, please allow this mail in your kindle doc service + ''; + }; + + cronJobs = mkOption { + type = types.attrsOf (types.submodule (import ./cronjob-options.nix { inherit config lib; })); + }; + }; +} diff --git a/programs/devel_progs.nix b/programs/devel_progs.nix index 0dd9a8a..f3eb16a 100644 --- a/programs/devel_progs.nix +++ b/programs/devel_progs.nix @@ -2,8 +2,6 @@ { environment.systemPackages = with pkgs; [ - firefox gitAndTools.gitFull git-cola git-crecord gitAndTools.git-extras git-lfs - gitAndTools.gitflow zsh-git-prompt cmakeWithGui qtcreator codeblocksFull eclipses.eclipse-cpp eclipses.eclipse-sdk clang gcc - gcc_multi automake atom kmod linuxHeaders tilix tmux screen bash gnumake ninja uncrustify hunspell hunspellDicts.en-us + gcc gcc_multi automake kmod linuxHeaders bash gnumake ]; } diff --git a/programs/zsh.nix b/programs/zsh.nix index 7cf7947..3179a3d 100644 --- a/programs/zsh.nix +++ b/programs/zsh.nix @@ -2,12 +2,8 @@ { programs.zsh = { - ohMyZsh = { - enable = true; - plugins = ["git" "git-extras" "git-flow"]; - }; enable = true; - enableAutosuggestions = true; + autosuggestions.enable = true; enableCompletion = true; syntaxHighlighting.enable = true; }; diff --git a/setup.nix b/setup.nix index 5ece109..433b7f3 100644 --- a/setup.nix +++ b/setup.nix @@ -2,5 +2,4 @@ { services.openssh.permitRootLogin = "yes"; - environment.systemPackages = [pkgs.nix-repl]; }