citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

default.nix (7582B)


      1 { composeKey, util, userConfig, theme, icon-theme, extra }:
      2 { config, lib, pkgs, ... }:
      3 let
      4   clippings-pl-file = pkgs.fetchurl {
      5     url = "https://raw.githubusercontent.com/jb55/kindle-clippings/master/clippings.pl";
      6     sha256 = "13bn5lvm4p85369yj88jr62h3zalmmyrzmjc332qwlqgqhyf3dls";
      7   };
      8   clippings-pl = util.writeBash "clippings.pl" ''
      9     ${lib.getBin pkgs.perl}/bin/perl ${clippings-pl-file}
     10   '';
     11 
     12   secrets = extra.private;
     13 in
     14 {
     15   imports = [
     16     (import ./networking extra)
     17   ];
     18 
     19   services.hoogle = {
     20     enable = false;
     21     port = 8088;
     22     packages = pkgs.myHaskellPackages;
     23     haskellPackages = pkgs.haskellPackages;
     24   };
     25 
     26   services.pcscd.enable = true;
     27   services.gnome.gnome-keyring.enable = if extra.is-minimal then false else true;
     28 
     29   services.trezord.enable = true;
     30 
     31   services.avahi.enable = true;
     32   services.avahi.publish.enable = true;
     33   services.avahi.publish.userServices = true;
     34 
     35   services.spotifyd.enable = false;
     36   services.spotifyd.config = ''
     37     [global]
     38     username = bcasarin
     39     password = ${secrets.spotify.password}
     40     backend = pulseaudio
     41     bitrate = 160
     42     device_name = spotifyd
     43     no_audio_cache = true
     44     volume_normalisation = true
     45     normalisation_pregain = -10
     46   '';
     47 
     48   programs.gnupg.agent.enable = true;
     49   programs.gnupg.agent.pinentryFlavor = "gtk2";
     50 
     51   # programs.gnupg.trezor-agent = {
     52   #   enable = if extra.is-minimal then false else true;
     53   #   configPath = "/home/jb55/.gnupg";
     54   # };
     55 
     56   services.redshift = {
     57     enable = if extra.is-minimal then false else true;
     58     temperature.day = 5500;
     59     temperature.night = 3800;
     60 
     61     brightness = {
     62       day = "1.0";
     63       night = "0.8";
     64     };
     65   };
     66 
     67   location.latitude = 49.270186;
     68   location.longitude = -123.109353;
     69 
     70   systemd.user.services.udiskie =  {
     71     enable = if extra.is-minimal then false else true;
     72     description = "userspace removable drive automounter";
     73     after    = [ "multi-user.target" ];
     74     wants    = [ "multi-user.target" ];
     75     wantedBy = [ "multi-user.target" ];
     76     serviceConfig = {
     77       Type = "simple";
     78       ExecStart = "${lib.getBin pkgs.udiskie}/bin/udiskie";
     79     };
     80   };
     81 
     82   systemd.user.services.udp-notify-daemon = {
     83     enable = true;
     84     description = "udp notification daemon";
     85     wantedBy = [ "default.target" ];
     86     after    = [ "default.target" ];
     87 
     88     path = with pkgs; [ bash gnupg libnotify netcat nettools ];
     89 
     90     serviceConfig.ExecStart = util.writeBash "notify-daemon" ''
     91       exec ${pkgs.socat}/bin/socat -d -d udp4-recvfrom:${toString extra.private.notify-port},reuseaddr,fork exec:/home/jb55/bin/recvalert
     92     '';
     93   };
     94 
     95   systemd.user.services.kindle-sync3 = {
     96     enable = false;
     97     description = "sync kindle";
     98     after    = [ "media-kindle.mount" ];
     99     requires = [ "media-kindle.mount" ];
    100     wantedBy = [ "media-kindle.mount" ];
    101     serviceConfig = {
    102       ExecStart = util.writeBash "kindle-sync" ''
    103         export PATH=${lib.makeBinPath (with pkgs; [ coreutils eject perl dos2unix git ])}:$PATH
    104         NOTES=/home/jb55/doc/notes/kindle
    105         mkdir -p $NOTES
    106         </media/kindle/documents/My\ Clippings.txt dos2unix | \
    107           ${clippings-pl} > $NOTES/clippings.yml
    108         cd $NOTES
    109         if [ ! -d ".git" ]; then
    110           git init .
    111           git remote add origin gh:jb55/my-clippings
    112         fi
    113         git add clippings.yml
    114         git commit -m "update"
    115         git push -u origin master
    116       '';
    117     };
    118   };
    119 
    120   services.mpd = {
    121     enable = false;
    122     dataDir = "/home/jb55/mpd";
    123     user = "jb55";
    124     group = "users";
    125     extraConfig = ''
    126       audio_output {
    127         type     "pulse"
    128         name     "Local MPD"
    129         server   "127.0.0.1"
    130       }
    131     '';
    132   };
    133 
    134   services.xserver = {
    135     enable = true;
    136     layout = "us";
    137 
    138     # xset r rate 200 50
    139     autoRepeatDelay = 200;
    140     autoRepeatInterval = 50;
    141 
    142     xkbOptions = "terminate:ctrl_alt_bksp,  ctrl:nocaps, keypad:hex, altwin:swap_alt_win, lv3:ralt_switch, compose:${composeKey}";
    143 
    144     wacom.enable = false;
    145 
    146     displayManager = {
    147       defaultSession = "none+xmonad";
    148       sessionCommands = "${userConfig}/bin/xinitrc";
    149       lightdm = {
    150         enable = true;
    151         background = "${pkgs.fetchurl {
    152           url = "https://jb55.com/s/red-low-poly.png";
    153           sha256 = "e45cc45eb084d615babfae1aae703757c814d544e056f0627d175a6ab18b35ab";
    154         }}";
    155       };
    156     };
    157 
    158     windowManager = {
    159       xmonad = {
    160         enable = true;
    161         enableContribAndExtras = true;
    162       };
    163     };
    164 
    165     desktopManager = {
    166       xterm.enable = false;
    167     };
    168 
    169   };
    170 
    171   # Enable the OpenSSH daemon.
    172   # Enable CUPS to print documents.
    173   services.printing = {
    174     enable = if extra.is-minimal then false else true;
    175     drivers = [ pkgs.gutenprint ] ;
    176   };
    177 
    178   systemd.user.services.sync-calendar = {
    179     enable   = if extra.is-minimal then false else true;
    180     description = "Calendar Sync";
    181     wantedBy = [ "graphical-session.target" ];
    182     after    = [ "graphical-session.target" ];
    183     serviceConfig.ExecStart = "${pkgs.vdirsyncer}/bin/vdirsyncer sync";
    184     startAt = "*:0/15";
    185   };
    186 
    187   systemd.user.services.standup = {
    188     enable   = if extra.is-minimal then false else true;
    189     description = "Standup notification";
    190     wantedBy = [ "graphical-session.target" ];
    191     after    = [ "graphical-session.target" ];
    192     serviceConfig.ExecStart = "${pkgs.libnotify}/bin/notify-send -u critical standup";
    193     startAt = "Mon..Fri *-*-* 15:58:00";
    194   };
    195 
    196   systemd.user.services.urxvtd = {
    197     enable = true;
    198     description = "RXVT-Unicode Daemon";
    199     wantedBy = [ "graphical-session.target" ];
    200     after    = [ "graphical-session.target" ];
    201     path = [ pkgs.rxvt-unicode ];
    202     serviceConfig = {
    203       Restart = "always";
    204       ExecStart = "${pkgs.rxvt-unicode}/bin/urxvtd -q -o";
    205     };
    206   };
    207 
    208   systemd.user.services.xautolock = {
    209     enable      = true;
    210     description = "X auto screen locker";
    211     wantedBy    = [ "graphical-session.target" ];
    212     after       = [ "graphical-session.target" ];
    213     serviceConfig.ExecStart = "${pkgs.xautolock}/bin/xautolock -time 10 -locker ${pkgs.slock}/bin/slock";
    214   };
    215 
    216   services.clipmenu.enable = true;
    217 
    218   #environment.systemPackages = [pkgs.phonectl];
    219   #systemd.user.services.phonectl = {
    220   #  enable      = if extra.is-minimal then false else true;
    221   #  description = "phonectl";
    222   #  wantedBy = [ "graphical-session.target" ];
    223   #  after    = [ "graphical-session.target" ];
    224 
    225   #  serviceConfig.ExecStart = "${pkgs.phonectl}/bin/phonectld";
    226 
    227   #  environment = with secrets.phonectl; {
    228   #    PHONECTLUSER=user;
    229   #    PHONECTLPASS=pass;
    230   #    PHONECTLPHONE=phone;
    231   #  };
    232   #};
    233 
    234   # TODO: maybe doesn't have my package env
    235   # systemd.user.services.xbindkeys = {
    236   #   enable      = true;
    237   #   description = "X key bind helper";
    238   #   wantedBy    = [ "graphical-session.target" ];
    239   #   after       = [ "graphical-session.target" ];
    240   #   serviceConfig.ExecStart = "${pkgs.xbindkeys}/bin/xbindkeys -n -f ${pkgs.jb55-dotfiles}/.xbindkeysrc";
    241   # };
    242 
    243   systemd.user.services.dunst = {
    244     enable      = if extra.is-minimal then false else true;
    245 
    246     description = "dunst notifier";
    247     wantedBy    = [ "graphical-session.target" ];
    248     after       = [ "graphical-session.target" ];
    249     serviceConfig.ExecStart = "${pkgs.dunst}/bin/dunst";
    250   };
    251 
    252   systemd.user.services.xinitrc = {
    253     enable      = true;
    254     description = "X session init commands";
    255     wantedBy    = [ "graphical-session.target" ];
    256     after       = [ "graphical-session.target" ];
    257 
    258     serviceConfig = {
    259       Type = "oneshot";
    260       RemainAfterExit = true;
    261       ExecStart = "${userConfig}/bin/xinitrc";
    262     };
    263   };
    264 
    265 }