moved all to subfolder nixos
This commit is contained in:
parent
78d39395b7
commit
15c6866362
263 changed files with 638 additions and 762 deletions
43
nixos/modules/default.nix
Normal file
43
nixos/modules/default.nix
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
|
||||
imports = [
|
||||
|
||||
./services/light-control.nix
|
||||
|
||||
./services/castget.nix
|
||||
./services/home-assistant.nix
|
||||
./services/lektor.nix
|
||||
./services/samba-share.nix
|
||||
./services/sshd.nix
|
||||
./services/videoencoder.nix
|
||||
|
||||
./programs/browser.nix
|
||||
./programs/citate.nix
|
||||
./programs/curl-scripts.nix
|
||||
./programs/easytag.nix
|
||||
./programs/elm.nix
|
||||
./programs/espeak.nix
|
||||
./programs/ffmpeg.nix
|
||||
./programs/git.nix
|
||||
./programs/shell-bash.nix
|
||||
./programs/shell-tools.nix
|
||||
./programs/shell-zsh.nix
|
||||
./programs/slack.nix
|
||||
./programs/steam.nix
|
||||
./programs/taskwarrior.nix
|
||||
./programs/urxvt.nix
|
||||
./programs/video.nix
|
||||
./programs/vim.nix
|
||||
./programs/xterm.nix
|
||||
|
||||
./system/audio.nix
|
||||
./system/bluetooth.nix
|
||||
./system/font.nix
|
||||
./system/mainUser.nix
|
||||
./system/permown.nix
|
||||
./system/wifi.nix
|
||||
./system/x11.nix
|
||||
./system/on-failure.nix
|
||||
|
||||
];
|
||||
}
|
251
nixos/modules/programs/browser.nix
Normal file
251
nixos/modules/programs/browser.nix
Normal file
|
@ -0,0 +1,251 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
# todo : this needs to be cleaned up
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.browser;
|
||||
library = import ../../library { inherit pkgs lib; };
|
||||
|
||||
chromiumBin = "${pkgs.chromium}/bin/chromium";
|
||||
chromeBin = "${pkgs.google-chrome}/bin/google-chrome-stable";
|
||||
firefoxBin = "${pkgs.firefox}/bin/firefox";
|
||||
tarBin = "${pkgs.gnutar}/bin/tar";
|
||||
|
||||
# desktop file
|
||||
# ------------
|
||||
# makes it possible to be used by other programs
|
||||
desktopFile = bin:
|
||||
let browserName = bin.name;
|
||||
in pkgs.writeTextFile {
|
||||
name = "${browserName}.desktop";
|
||||
destination = "/share/applications/${browserName}.desktop";
|
||||
text = ''
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Exec=${bin}/bin/${browserName} %U
|
||||
Icon=chromium
|
||||
Comment=An open source web browser from Google
|
||||
Terminal=false
|
||||
Name=${browserName}
|
||||
GenericName=Web browser
|
||||
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/webcal;x-scheme-handler/about
|
||||
Categories=Network;WebBrowser
|
||||
StartupWMClass=${browserName}
|
||||
'';
|
||||
};
|
||||
|
||||
killBrowser = name:
|
||||
pkgs.writeShellScriptBin "${name}-kill" "sudo killall -9 -u ${name}";
|
||||
|
||||
cleanBrowser = name: browser: home: homeBackup:
|
||||
let
|
||||
backupFile = "${homeBackup}.tar.lzma";
|
||||
rolloutFile = "${home}.tar.lzma";
|
||||
lockFile = "${home}-lock";
|
||||
in pkgs.writeShellScriptBin "${name}-clean" # sh
|
||||
''
|
||||
sudo killall -9 -u ${name}
|
||||
sudo rm -f ${lockFile}
|
||||
sudo rm -rf ${home}
|
||||
'';
|
||||
|
||||
createBrowser = name: user: browser: home: homeBackup:
|
||||
let
|
||||
backupFile = "${homeBackup}.tar.lzma";
|
||||
rolloutFile = "${home}.tar.lzma";
|
||||
lockFile = "${home}-lock";
|
||||
in pkgs.writeShellScriptBin "${name}" # sh
|
||||
''
|
||||
# set -x
|
||||
if [[ ! -e ${lockFile} ]]
|
||||
then
|
||||
# rollout backup
|
||||
if [[ -e ${backupFile} ]]
|
||||
then
|
||||
if [[ ! -d ${home} ]]
|
||||
then
|
||||
# todo : use make user
|
||||
sudo mkdir -p ${home}
|
||||
sudo chown -R ${user}:users ${home}
|
||||
fi
|
||||
cp ${backupFile} ${rolloutFile}
|
||||
sudo -u ${user} ${tarBin} xf ${rolloutFile} --directory ${home}
|
||||
rm ${rolloutFile}
|
||||
touch ${lockFile}
|
||||
fi
|
||||
fi
|
||||
|
||||
sudo -u ${user} ${browser}
|
||||
'';
|
||||
|
||||
browserExecutableList = let
|
||||
allBrowser = flip mapAttrsToList cfg.configList (name: config:
|
||||
let
|
||||
browser = if config.browserType == "chrome" then
|
||||
''${chromiumBin} "$@"''
|
||||
else if config.browserType == "google" then
|
||||
''${chromeBin} "$@"''
|
||||
else
|
||||
''${firefoxBin} "$@"'';
|
||||
in createBrowser name config.user browser config.home config.homeBackup);
|
||||
xclipBrowser = [
|
||||
(pkgs.writeShellScriptBin "copy-to-xclip" # sh
|
||||
''
|
||||
echo "$*" | ${pkgs.xclip}/bin/xclip
|
||||
'')
|
||||
];
|
||||
in allBrowser ++ xclipBrowser;
|
||||
|
||||
createBackupScript = name: home: backupHome:
|
||||
pkgs.writeShellScriptBin "${name}-backup" # sh
|
||||
''
|
||||
sudo -u ${name} \
|
||||
${tarBin} \
|
||||
--exclude=.cache \
|
||||
--exclude=Downloads \
|
||||
--create \
|
||||
--verbos \
|
||||
--lzma \
|
||||
--file ${home}.tar.lzma \
|
||||
--directory ${home} \
|
||||
.
|
||||
|
||||
cp ${home}.tar.lzma ${backupHome}.tar.lzma
|
||||
'';
|
||||
|
||||
allBackupScripts = let
|
||||
filteredConfigs =
|
||||
filterAttrs (name: browserConfig: browserConfig.homeBackup != null)
|
||||
cfg.configList;
|
||||
in mapAttrsToList (name: browserConfig:
|
||||
createBackupScript name browserConfig.home browserConfig.homeBackup)
|
||||
filteredConfigs;
|
||||
|
||||
allCleanScripts = let
|
||||
filteredConfigs =
|
||||
filterAttrs (name: browserConfig: browserConfig.homeBackup != null)
|
||||
cfg.configList;
|
||||
in mapAttrsToList (name: browserConfig:
|
||||
cleanBrowser name name browserConfig.home browserConfig.homeBackup)
|
||||
filteredConfigs;
|
||||
|
||||
allKillScripts = mapAttrsToList (name: _: killBrowser name) cfg.configList;
|
||||
|
||||
# browser chooser
|
||||
# ---------------
|
||||
browserSelect = pkgs.writeScriptBin "browser-select" ''
|
||||
# select a browser using dmenu
|
||||
# ----------------------------
|
||||
BROWSER=$( echo -e "${
|
||||
lib.concatMapStringsSep "\\n" (bin: bin.name) browserExecutableList
|
||||
}" \
|
||||
| ${pkgs.rofi}/bin/rofi -dmenu )
|
||||
|
||||
# start selected browser
|
||||
# ----------------------
|
||||
case $BROWSER in
|
||||
${lib.concatStringsSep "\n" (flip map browserExecutableList
|
||||
(bin: "${bin.name}) export BIN=${bin}/bin/${bin.name} ;;"))}
|
||||
esac
|
||||
$BIN "$@"
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.browser = {
|
||||
enable = mkEnableOption "enable browsers";
|
||||
configList = mkOption {
|
||||
type = with types;
|
||||
attrsOf (submodule ({ name, ... }: {
|
||||
options = {
|
||||
browserType = mkOption {
|
||||
type = with types; enum [ "firefox" "chrome" "google" ];
|
||||
default = "chrome";
|
||||
description = ''
|
||||
the type of browser which is simulated
|
||||
'';
|
||||
};
|
||||
home = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
Home of the browser.
|
||||
'';
|
||||
};
|
||||
gpu = mkOption {
|
||||
type = with types; bool;
|
||||
default = true;
|
||||
description = ''
|
||||
add browser user to video group so give browser rights to use gpu.
|
||||
see : chrome://gpu/
|
||||
'';
|
||||
};
|
||||
user = mkOption {
|
||||
default = name;
|
||||
type = with types; str;
|
||||
description = ''
|
||||
user to run the browser as
|
||||
'';
|
||||
};
|
||||
sudoUsers = mkOption {
|
||||
default = [ config.users.users.mainUser.name ];
|
||||
type = with types; listOf str;
|
||||
description = ''
|
||||
user allowed to run sudo without password to start the browser
|
||||
'';
|
||||
};
|
||||
homeBackup = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
example = "~/.my-browser-backup";
|
||||
description = ''
|
||||
backup of the home, which gets rolled out if the
|
||||
home does not exists. usefull for homes in tmpfs.
|
||||
dont use file endings!
|
||||
'';
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# add sudo rights
|
||||
security.sudo.extraConfig = let
|
||||
extraRules = flip mapAttrsToList cfg.configList (name: values:
|
||||
concatStringsSep "" (map (sudoUser: ''
|
||||
# sudo configuration to control browser
|
||||
${sudoUser} ALL=(${values.user}) NOPASSWD: ALL
|
||||
${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/mkdir -p ${values.home}
|
||||
${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/chown -R ${values.user}\:users ${values.home}
|
||||
${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/killall -9 -u ${name}
|
||||
${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/rm -rf ${values.home}
|
||||
${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/rm -f ${values.home}-lock
|
||||
'') values.sudoUsers));
|
||||
in lib.concatStringsSep "\n" extraRules;
|
||||
|
||||
# create users
|
||||
users.users = flip mapAttrs cfg.configList (name: config: {
|
||||
home = config.home;
|
||||
createHome = true;
|
||||
initialPassword = "${name}-browser";
|
||||
shell = pkgs.bashInteractive;
|
||||
isNormalUser = true;
|
||||
group = "users";
|
||||
# enable video usage
|
||||
extraGroups = if config.gpu then [ "video" "audio" ] else [ "audio" ];
|
||||
});
|
||||
|
||||
# add groups to mainUser
|
||||
system.custom.mainUser.extraGroups = builtins.attrNames cfg.configList;
|
||||
|
||||
environment.systemPackages = [ browserSelect (desktopFile browserSelect) ]
|
||||
++ browserExecutableList
|
||||
++ (map (bin: desktopFile bin) browserExecutableList) ++ allBackupScripts
|
||||
++ allCleanScripts ++ allKillScripts;
|
||||
|
||||
};
|
||||
}
|
42
nixos/modules/programs/citate.nix
Normal file
42
nixos/modules/programs/citate.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.citate;
|
||||
|
||||
library = import ../../library { inherit pkgs lib; };
|
||||
|
||||
xdotool = "${pkgs.xdotool}/bin/xdotool";
|
||||
dmenu = "${pkgs.dmenu}/bin/dmenu";
|
||||
|
||||
citateScript = file: suffix:
|
||||
pkgs.writeShellScriptBin "citate-${suffix}" ''
|
||||
${xdotool} - <<<"type -- $( cat ${file} | ${dmenu} -l 10 -i | sed -e "s/\(.*\)/'\1'/" )"
|
||||
'';
|
||||
|
||||
scriptAxel = citateScript (toString ../../assets/sprueche-axel) "axel";
|
||||
scriptSiw = citateScript (toString ../../assets/sprueche-siw) "siw";
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.citate = {
|
||||
enable = mkEnableOption "enable programs.custom.citate";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [
|
||||
scriptAxel
|
||||
(library.desktopFile scriptAxel {
|
||||
longName = "Citate Axel";
|
||||
command = "citate-axel";
|
||||
})
|
||||
scriptSiw
|
||||
(library.desktopFile scriptSiw {
|
||||
longName = "Citate Sinnlos im Weltall";
|
||||
command = "citate-siw";
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
31
nixos/modules/programs/curl-scripts.nix
Normal file
31
nixos/modules/programs/curl-scripts.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
weatherScript = pkgs.writeShellScriptBin "weather" ''
|
||||
${pkgs.curl}/bin/curl wttr.in/Berlin
|
||||
'';
|
||||
|
||||
qrCodeScript = pkgs.writeShellScriptBin "qrCode" ''
|
||||
${pkgs.qrencode}/bin/qrencode -t ANSI -o - "$@"
|
||||
'';
|
||||
|
||||
cheatSheetScript = pkgs.writeShellScriptBin "cheatsheet" ''
|
||||
${pkgs.curl}/bin/curl "cheat.sh/$1"
|
||||
'';
|
||||
|
||||
cfg = config.programs.custom.curlScripts;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.curlScripts.enable =
|
||||
mkEnableOption "enable curl scripts";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages =
|
||||
[ weatherScript qrCodeScript cheatSheetScript pkgs.qrencode ];
|
||||
};
|
||||
}
|
||||
|
18
nixos/modules/programs/easytag.nix
Normal file
18
nixos/modules/programs/easytag.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.easytag;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.easytag.enable =
|
||||
mkEnableOption "install easytag with dependencies";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [ easytag gnome3.dconf ];
|
||||
};
|
||||
}
|
||||
|
24
nixos/modules/programs/elm.nix
Normal file
24
nixos/modules/programs/elm.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.elm;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.elm.enable = mkEnableOption "enable elm stack";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
elmPackages.elm
|
||||
elmPackages.elm-compiler
|
||||
elmPackages.elm-format
|
||||
elmPackages.elm-make
|
||||
elmPackages.elm-reactor
|
||||
elm-github-install
|
||||
];
|
||||
};
|
||||
}
|
||||
|
50
nixos/modules/programs/espeak.nix
Normal file
50
nixos/modules/programs/espeak.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
espeak = pkgs.unstable.espeak;
|
||||
|
||||
# can't use bash aliases because programms will not pic it up
|
||||
en_espeak = pkgs.writeShellScriptBin "en-speak" ''
|
||||
exec ${espeak}/bin/espeak \
|
||||
-v en\
|
||||
-s 145 \
|
||||
-p 23 \
|
||||
"$@"
|
||||
'';
|
||||
|
||||
# read from copyq
|
||||
en_read = pkgs.writeShellScriptBin "en-read" ''
|
||||
exec ${pkgs.copyq}/bin/copyq read 0 | ${en_espeak}/bin/en-speak
|
||||
'';
|
||||
|
||||
# can't use bash aliases because programms will not pic it up
|
||||
de_espeak = pkgs.writeShellScriptBin "de-speak" ''
|
||||
exec ${espeak}/bin/espeak \
|
||||
-v de\
|
||||
-s 143 \
|
||||
-p 20 \
|
||||
"$@"
|
||||
'';
|
||||
|
||||
# read from copyq
|
||||
de_read = pkgs.writeShellScriptBin "de-read" ''
|
||||
exec ${pkgs.copyq}/bin/copyq read 0 | ${de_espeak}/bin/de-speak
|
||||
'';
|
||||
|
||||
cfg = config.programs.custom.espeak;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.espeak.enable =
|
||||
mkEnableOption "enable espeak scripts";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ espeak en_espeak en_read de_espeak de_read ];
|
||||
|
||||
};
|
||||
}
|
||||
|
151
nixos/modules/programs/ffmpeg.nix
Normal file
151
nixos/modules/programs/ffmpeg.nix
Normal file
|
@ -0,0 +1,151 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.ffmpeg;
|
||||
|
||||
ffmpegTemplate = name:
|
||||
{ profile, preset, tune ? null, width ? 1280, height ? 720
|
||||
, resolution ? "720p" }:
|
||||
pkgs.writeShellScriptBin "ffmpeg-${name}" ''
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
cat <<EOF
|
||||
ffmpeg-<profile>-<preset>-<tunes>-${resolution} <input> <output>
|
||||
|
||||
profiles =
|
||||
"baseline" - Primarily for low-cost applications that require additional data loss robustness
|
||||
"main" - This profile is used for standard-definition digital TV broadcasts that use the MPEG-4 format as defined in the DVB standard.
|
||||
"high" - The primary profile for broadcast and disc storage applications, particularly for high-definition television applications
|
||||
|
||||
presets =
|
||||
"ultrafast"
|
||||
"superfast"
|
||||
"veryfast"
|
||||
"faster"
|
||||
"fast"
|
||||
"medium"
|
||||
"slow"
|
||||
"slower"
|
||||
"veryslow"
|
||||
|
||||
tunes = (optional)
|
||||
"film" - use for high quality movie content; lowers deblockin
|
||||
"animation" - good for cartoons; uses higher deblocking and more reference frames
|
||||
"grain" - preserves the grain structure in old, grainy film material
|
||||
"stillimage" - good for slideshow-like content
|
||||
"fastdecode" - allows faster decoding by disabling certain filters
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $# -ne 2 ]
|
||||
then
|
||||
echo "ffmpeg-${name} <input> <output>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input=$1
|
||||
output=$2
|
||||
|
||||
if [ ! -f "$input" ]
|
||||
then
|
||||
echo "input does not exist $input"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# do it stereo
|
||||
# -ac 2
|
||||
# do it sample rate 44100
|
||||
# -ar 44100
|
||||
|
||||
exec ${pkgs.ffmpeg}/bin/ffmpeg \
|
||||
-i "$input" \
|
||||
-filter:v scale=h='min(${toString height}\,ih)':w='min(${
|
||||
toString width
|
||||
}\,iw)' \
|
||||
-vcodec libx264 \
|
||||
-preset ${preset} \
|
||||
-profile:v ${profile} \
|
||||
${optionalString (tune != null) "-tune ${tune}"} \
|
||||
-acodec aac \
|
||||
-ac 2 \
|
||||
-ar 44100 \
|
||||
"$output" \
|
||||
-hide_banner
|
||||
'';
|
||||
|
||||
# https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles
|
||||
profiles = [
|
||||
"baseline"
|
||||
"main"
|
||||
"high"
|
||||
#"high10"
|
||||
#"high422"
|
||||
#"high44"
|
||||
];
|
||||
presets = [
|
||||
#"ultrafast"
|
||||
#"superfast"
|
||||
#"veryfast"
|
||||
#"faster"
|
||||
"fast"
|
||||
"medium"
|
||||
"slow"
|
||||
#"slower"
|
||||
"veryslow"
|
||||
];
|
||||
tunes = [ "film" "animation" "grain" "stillimage" "fastdecode" ];
|
||||
|
||||
ffmpegs = let
|
||||
|
||||
configurations = lib.cartesianProductOfSets {
|
||||
profile = profiles;
|
||||
preset = presets;
|
||||
};
|
||||
|
||||
p720 = { profile, preset }:
|
||||
ffmpegTemplate "${profile}-${preset}-720p" { inherit profile preset; };
|
||||
|
||||
p1080 = { profile, preset }:
|
||||
ffmpegTemplate "${profile}-${preset}-1080p" {
|
||||
inherit profile preset;
|
||||
height = 1080;
|
||||
width = 1920;
|
||||
resolution = "1080p";
|
||||
};
|
||||
in (map p720 configurations) ++ (map p1080 configurations);
|
||||
|
||||
ffmpegsTune = let
|
||||
configurations = lib.cartesianProductOfSets {
|
||||
profile = profiles;
|
||||
preset = presets;
|
||||
tune = tunes;
|
||||
};
|
||||
|
||||
p720 = { profile, preset, tune }:
|
||||
ffmpegTemplate "${profile}-${preset}-${tune}-720p" {
|
||||
inherit profile preset tune;
|
||||
};
|
||||
|
||||
p1080 = { profile, preset, tune }:
|
||||
ffmpegTemplate "${profile}-${preset}-${tune}-1080p" {
|
||||
inherit profile preset tune;
|
||||
height = 1080;
|
||||
width = 1920;
|
||||
resolution = "1080p";
|
||||
};
|
||||
|
||||
in (map p720 configurations) ++ (map p1080 configurations);
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.ffmpeg = {
|
||||
enable = mkEnableOption "enable programs.custom.ffmpeg";
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable { environment.systemPackages = ffmpegs ++ ffmpegsTune; };
|
||||
}
|
34
nixos/modules/programs/git.nix
Normal file
34
nixos/modules/programs/git.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.git;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.git.enable =
|
||||
mkEnableOption "install git and all its tools";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
tig
|
||||
lazygit
|
||||
git-crypt
|
||||
gitAndTools.gitflow
|
||||
gitAndTools.gitSVN
|
||||
gitAndTools.git2cl
|
||||
|
||||
# merge tools
|
||||
meld
|
||||
|
||||
# activate using :
|
||||
# git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
|
||||
gitAndTools.diff-so-fancy
|
||||
];
|
||||
};
|
||||
}
|
||||
|
84
nixos/modules/programs/shell-bash.nix
Normal file
84
nixos/modules/programs/shell-bash.nix
Normal file
|
@ -0,0 +1,84 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let cfg = config.programs.custom.bash;
|
||||
in {
|
||||
|
||||
options.programs.custom.bash.enable = lib.mkEnableOption "enable bash config";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
programs.bash = {
|
||||
|
||||
# BashCompletion
|
||||
# --------------
|
||||
enableCompletion = true;
|
||||
|
||||
# Configure Shell
|
||||
# ---------------
|
||||
interactiveShellInit = # sh
|
||||
''
|
||||
# use vi shortcuts
|
||||
# ----------------
|
||||
set -o vi
|
||||
|
||||
# Configure ls-colors
|
||||
# -------------------
|
||||
export LS_COLORS='rs=0:di=01;35:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;33:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35::*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
|
||||
'';
|
||||
|
||||
# Configure Prompt
|
||||
# ----------------
|
||||
promptInit = # sh
|
||||
''
|
||||
# PS1 content functions
|
||||
# ---------------------
|
||||
function nonzero_return() {
|
||||
RETVAL=$?
|
||||
[ $RETVAL -ne 0 ] && echo "[> $RETVAL <] "
|
||||
}
|
||||
|
||||
# Provide a nice prompt
|
||||
# ---------------------
|
||||
case $TERM in
|
||||
xterm*|rxvt*|Eterm)
|
||||
# used : http://ezprompt.net/
|
||||
USER_COLOR="\[\e[36m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[36m\]\h\[\e[m\]"
|
||||
CURRENT_PATH="\[\e[33m\][\[\e[m\]\[\e[33m\]\w\[\e[m\]\[\e[33m\]]\[\e[m\]"
|
||||
if [[ $UID -eq 0 ]]
|
||||
then
|
||||
USER_COLOR="\[\e[31m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[31m\]\h\[\e[m\]"
|
||||
fi
|
||||
export PS1="\[\e[31m\]\`nonzero_return\`\[\e[m\]\[\e[35m\]\A\[\e[m\] $USER_COLOR $CURRENT_PATH\[\e[31m\]\\$\[\e[m\] "
|
||||
;;
|
||||
screen)
|
||||
export PS1="\[\e[31m\]\`nonzero_return\`\[\e[m\]\[\e[35m\]\A\[\e[m\] \[\e[36m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[36m\]\h\[\e[m\] \[\e[33m\][\[\e[m\]\[\e[33m\]\W\[\e[m\]\[\e[33m\]]\[\e[m\]\[\e[31m\]\\$\[\e[m\] "
|
||||
;;
|
||||
esac
|
||||
'';
|
||||
|
||||
# Shell Aliases
|
||||
# -------------
|
||||
shellAliases = {
|
||||
ls = "ls --color=tty";
|
||||
l = "ls -CFh";
|
||||
la = "ls -Ah";
|
||||
ll = "ls -lh";
|
||||
lt = "ls -lct --reverse";
|
||||
less = "less -S";
|
||||
top = "htop";
|
||||
version = "date '+%Y%m%d%H%M%S'";
|
||||
vclip = "xclip -selection clipboard";
|
||||
df = "df -h";
|
||||
|
||||
nix-search = "nix-env -qaP";
|
||||
nix-list = ''nix-env -qaP "*" --description'';
|
||||
nix-list-haskell = ''nix-env -f "<nixpkgs>" -qaP -A haskellPackages'';
|
||||
|
||||
nix-show-garbadge-roots = "ls -lh /nix/var/nix/gcroots/auto/";
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
42
nixos/modules/programs/shell-tools.nix
Normal file
42
nixos/modules/programs/shell-tools.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
xterm-colors = pkgs.writeShellScriptBin "256-xterm-colors"
|
||||
# sh
|
||||
''
|
||||
for i in {0..255} ; do
|
||||
printf "\x1b[38;5;%sm%3d\e[0m " "$i" "$i"
|
||||
if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
|
||||
printf "\n";
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
xterm-background-colors = pkgs.writeShellScriptBin
|
||||
"256-xterm-colors-background"
|
||||
# sh
|
||||
''
|
||||
for i in {0..255} ; do
|
||||
printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
|
||||
if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
|
||||
printf "\n";
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
cfg = config.programs.custom.shellTools;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.shellTools.enable =
|
||||
mkEnableOption "enable shell tools";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ xterm-colors xterm-background-colors ];
|
||||
};
|
||||
|
||||
}
|
||||
|
175
nixos/modules/programs/shell-zsh.nix
Normal file
175
nixos/modules/programs/shell-zsh.nix
Normal file
|
@ -0,0 +1,175 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.zsh;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.zsh = {
|
||||
enable = mkEnableOption "enable zsh";
|
||||
|
||||
mainUser = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
the main User if available
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
programs.zsh = {
|
||||
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
#autosuggestions.enable = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
|
||||
ohMyZsh = {
|
||||
|
||||
custom = "/etc/zshcustom/";
|
||||
enable = true;
|
||||
|
||||
# powerline themes
|
||||
# ----------------
|
||||
#theme = "agnoster";
|
||||
theme = "powerlevel9k/powerlevel9k";
|
||||
|
||||
plugins = [
|
||||
"git"
|
||||
"git-flow"
|
||||
"screen"
|
||||
"taskwarrior"
|
||||
"systemd"
|
||||
"tmux"
|
||||
"vi-mode"
|
||||
"wd"
|
||||
];
|
||||
};
|
||||
|
||||
loginShellInit = ''
|
||||
export TERM="xterm-256color"
|
||||
'';
|
||||
shellAliases = {
|
||||
ls = "ls --color=tty";
|
||||
l = "ls -CFh";
|
||||
la = "ls -Ah";
|
||||
ll = "ls -lh";
|
||||
lt = "ls -lct --reverse";
|
||||
less = "less -S";
|
||||
top = "htop";
|
||||
version = "date '+%Y%m%d%H%M%S'";
|
||||
vclip = "xclip -selection clipboard";
|
||||
df = "df -h";
|
||||
|
||||
timestamp = "date +%Y%m%d%H%M%S";
|
||||
|
||||
nix-search = "nix-env -qaP";
|
||||
nix-list = ''nix-env -qaP "*" --description'';
|
||||
nix-list-haskell = ''nix-env -f "<nixpkgs>" -qaP -A haskellPackages'';
|
||||
nix-list-node = ''nix-env -f "<nixpkgs>" -qaP -A nodePackages'';
|
||||
nix-list-beam = ''nix-env -f "<nixpkgs>" -qaP -A beamPackages'';
|
||||
# nix-find = "clear ; ${pkgs.nix-index}/bin/nix-locate -1 -w";
|
||||
|
||||
nix-show-garbadge-roots = "ls -lh /nix/var/nix/gcroots/auto/";
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#environment.systemPackages = [
|
||||
# pkgs.nix-index # make nix-index also available to users
|
||||
#];
|
||||
|
||||
# only used to make quick config changes
|
||||
# --------------------------------------
|
||||
environment.etc."zshcustom/mainuser.zsh".source =
|
||||
pkgs.writeText "mainuser-zsh" (if (cfg.mainUser != null) then ''
|
||||
source ${config.users.users.mainUser.home}/.zshrc
|
||||
'' else
|
||||
"# programs.custom.zsh.mainUser not set ");
|
||||
|
||||
# Theme
|
||||
# -----
|
||||
# make sure powerline-fonts is set in `fonts.fonts`
|
||||
|
||||
environment.etc."zshcustom/themes/powerlevel9k".source =
|
||||
pkgs.fetchFromGitHub {
|
||||
owner = "bhilburn";
|
||||
repo = "powerlevel9k";
|
||||
rev = "v0.6.4";
|
||||
sha256 = "104wvlni3rilpw9v1dk848lnw8cm8qxl64xs70j04ly4s959dyb5";
|
||||
};
|
||||
environment.etc."zshcustom/powerlevel9kpatch.zsh".source =
|
||||
pkgs.writeText "powerlevel9kpatch.zsh" ''
|
||||
|
||||
# this shows all the colors which are available
|
||||
# ---------------------------------------------
|
||||
# for code ({000..255}) print -P -- "$code: %F{$code}This is how your text would look like%f"
|
||||
|
||||
# prompt elements
|
||||
# ---------------
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vi_mode context dir vcs custom_jail background_jobs time status)
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
|
||||
|
||||
# vi mode
|
||||
# -------
|
||||
POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND="black"
|
||||
POWERLEVEL9K_VI_MODE_INSERT_BACKGROUND="blue"
|
||||
POWERLEVEL9K_VI_MODE_NORMAL_FOREGROUND="black"
|
||||
POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND="yellow"
|
||||
|
||||
# context
|
||||
# -------
|
||||
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND="green"
|
||||
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND="008"
|
||||
POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND="008"
|
||||
POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND="red"
|
||||
POWERLEVEL9K_CONTEXT_REMOTE_FOREGROUND="008"
|
||||
POWERLEVEL9K_CONTEXT_REMOTE_BACKGROUND="red"
|
||||
|
||||
# dir
|
||||
# ---
|
||||
POWERLEVEL9K_DIR_HOME_FOREGROUND="black"
|
||||
POWERLEVEL9K_DIR_HOME_BACKGROUND="yellow"
|
||||
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="black"
|
||||
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="yellow"
|
||||
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="black"
|
||||
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="green"
|
||||
|
||||
# root_indicator
|
||||
# --------------
|
||||
POWERLEVEL9K_ROOT_ICON="#"
|
||||
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND="black"
|
||||
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND="red"
|
||||
|
||||
# background_jobs
|
||||
# ---------------
|
||||
POWERLEVEL9K_BACKGROUND_JOBS_ICON=""
|
||||
|
||||
# status
|
||||
# ------
|
||||
POWERLEVEL9K_STATUS_OK_BACKGROUND="008"
|
||||
POWERLEVEL9K_STATUS_ERROR_BACKGROUND="008"
|
||||
|
||||
# time
|
||||
# ----
|
||||
POWERLEVEL9K_TIME_FOREGROUND="008"
|
||||
POWERLEVEL9K_TIME_BACKGROUND="006"
|
||||
|
||||
|
||||
# jail indicator
|
||||
# --------------
|
||||
POWERLEVEL9K_CUSTOM_JAIL="[ -z $JAIL ] || echo $JAIL"
|
||||
POWERLEVEL9K_CUSTOM_JAIL_BACKGROUND="red"
|
||||
POWERLEVEL9K_CUSTOM_JAIL_FOREGROUND="black"
|
||||
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
122
nixos/modules/programs/slack.nix
Normal file
122
nixos/modules/programs/slack.nix
Normal file
|
@ -0,0 +1,122 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
# name of the program
|
||||
# -------------------
|
||||
program = "slack";
|
||||
|
||||
tarBin = "${pkgs.gnutar}/bin/tar";
|
||||
|
||||
# command that will be jailed
|
||||
# ---------------------------
|
||||
command = "${pkgs.slack}/bin/slack";
|
||||
|
||||
desktopFile = let
|
||||
name = program;
|
||||
comment = "Chat Programm";
|
||||
in pkgs.writeTextFile {
|
||||
name = "${name}.desktop";
|
||||
destination = "/share/applications/${name}.desktop";
|
||||
text = ''
|
||||
[Desktop Entry]
|
||||
Categories=Application;Utility;
|
||||
Comment=${comment}
|
||||
Encoding=UTF-8
|
||||
Exec=${bin}/bin/${name}
|
||||
Icon=gnome-lockscreen
|
||||
Name=${name}
|
||||
Terminal=false
|
||||
Type=Application
|
||||
'';
|
||||
};
|
||||
|
||||
# the script
|
||||
# ----------
|
||||
bin = let
|
||||
backupFile = "${cfg.homeBackup}.tar.lzma";
|
||||
rolloutFile = "${cfg.home}.tar.lzma";
|
||||
lockFile = "${cfg.home}-lock";
|
||||
in pkgs.writeShellScriptBin "${program}" ''
|
||||
# set -x
|
||||
if [[ ! -e ${lockFile} ]]
|
||||
then
|
||||
# rollout backup
|
||||
if [[ -e ${backupFile} ]]
|
||||
then
|
||||
cp ${backupFile} ${rolloutFile}
|
||||
sudo -u ${program} ${tarBin} xf ${rolloutFile} --directory ${cfg.home}
|
||||
rm ${rolloutFile}
|
||||
touch ${lockFile}
|
||||
fi
|
||||
fi
|
||||
|
||||
sudo -u ${program} ${command}
|
||||
'';
|
||||
|
||||
backupScript = pkgs.writeShellScriptBin "${program}-backup" ''
|
||||
sudo -u ${program} \
|
||||
${tarBin} \
|
||||
--exclude=.cache \
|
||||
--exclude=".config/**/*Cache*" \
|
||||
--exclude-cache-all \
|
||||
--exclude=Downloads \
|
||||
--create \
|
||||
--verbos \
|
||||
--lzma \
|
||||
--file ${cfg.home}.tar.lzma \
|
||||
--directory ${cfg.home} \
|
||||
.
|
||||
|
||||
cp ${cfg.home}.tar.lzma ${cfg.homeBackup}.tar.lzma
|
||||
'';
|
||||
|
||||
cfg = config.programs.custom.slack;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.slack = {
|
||||
enable = mkEnableOption "install slack";
|
||||
|
||||
homeBackup = mkOption {
|
||||
type = with types; nullOr string;
|
||||
description = ''
|
||||
folder where to backup
|
||||
'';
|
||||
};
|
||||
|
||||
# todo : make sure the folder /home/sudoers belongs to mainUser
|
||||
home = mkOption {
|
||||
type = with types; string;
|
||||
default = "/home/sudoers/slack";
|
||||
description = ''
|
||||
home folder of this
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
security.sudo.extraConfig = ''
|
||||
${config.users.users.mainUser.name} ALL=(${program}) NOPASSWD: ALL
|
||||
'';
|
||||
|
||||
# create users
|
||||
users.users."${program}" = {
|
||||
home = cfg.home;
|
||||
createHome = true;
|
||||
# initialPassword = "${program}";
|
||||
shell = pkgs.bashInteractive;
|
||||
isNormalUser = true;
|
||||
group = "users";
|
||||
# enable video usage
|
||||
extraGroups = [ "video" "audio" ];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ bin backupScript desktopFile ];
|
||||
};
|
||||
}
|
||||
|
47
nixos/modules/programs/steam.nix
Normal file
47
nixos/modules/programs/steam.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
# steam
|
||||
# -------
|
||||
# Don't forget to run 'xhost +' with your user
|
||||
# to make sure the browser user can write to X
|
||||
let
|
||||
|
||||
bin = pkgs.writeShellScriptBin "steam" ''
|
||||
/var/run/wrappers/bin/sudo -u steam -i ${pkgs.steam}/bin/steam $@
|
||||
'';
|
||||
|
||||
cfg = config.programs.custom.steam;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.steam.enable = mkEnableOption "enable steam";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [
|
||||
bin
|
||||
pkgs.xorg.xhost
|
||||
# to use xbox controllers
|
||||
pkgs.xboxdrv
|
||||
];
|
||||
|
||||
users.users.steam = {
|
||||
isNormalUser = true;
|
||||
home = "/home/steam";
|
||||
createHome = true;
|
||||
extraGroups = [ "audio" "input" "video" ];
|
||||
};
|
||||
|
||||
# for steam
|
||||
# ---------
|
||||
hardware.opengl.driSupport = true;
|
||||
hardware.opengl.driSupport32Bit = true;
|
||||
|
||||
security.sudo.extraConfig = ''
|
||||
${config.users.extraUsers.mainUser.name} ALL=(steam) NOPASSWD: ALL
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
88
nixos/modules/programs/taskwarrior.nix
Normal file
88
nixos/modules/programs/taskwarrior.nix
Normal file
|
@ -0,0 +1,88 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.taskwarrior;
|
||||
|
||||
taskNextWeek = pkgs.writeShellScriptBin "taskweek" # sh
|
||||
''
|
||||
${pkgs.taskwarrior}/bin/task \
|
||||
export \
|
||||
status:pending and \( due.before:6days \) \
|
||||
| ${pkgs.jq}/bin/jq '[.[] | { Day: .due, ID: .id, Description: .description } ] | sort_by(.Day)' \
|
||||
| ${pkgs.miller}/bin/mlr --ijson --opprint put "\$Day = strftime(strptime(\$Day,\"%Y%m%dT%H%M%SZ\")$(date +%z)00,\"%A\")"
|
||||
'';
|
||||
|
||||
tsak = pkgs.writeShellScriptBin "tsak" # sh
|
||||
''
|
||||
${pkgs.taskwarrior}/bin/task "$@"
|
||||
'';
|
||||
taskwarrior-tui = pkgs.unstable.taskwarrior-tui;
|
||||
|
||||
vit = pkgs.unstable.vit.overrideAttrs (old: rec {
|
||||
name = "vit-${version}";
|
||||
version = "master";
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://github.com/scottkosty/vit.git";
|
||||
#rev = "7200949214362139e8073b6ca1a58cc756b2ebd0";
|
||||
#sha256 = "1s0rvqn8xjy3qiw9034wfzz2r7mwary70x32fqprz2w2h5r73j2m";
|
||||
rev = "cfe5975bd054fe8ffe79527a1af6356528b60c63";
|
||||
sha256 = "12fjx91l7cxxan3pg0xqmizpabp5g482vxqq5f3r8b6dw70l15hk";
|
||||
};
|
||||
});
|
||||
#vit = pkgs.vit;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.taskwarrior.enable =
|
||||
mkEnableOption "Enable Taskwarrior services";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
taskwarrior-tui
|
||||
taskwarrior
|
||||
timewarrior
|
||||
tasksh
|
||||
taskNextWeek
|
||||
tsak
|
||||
|
||||
(pkgs.writers.writeBashBin "calendar" ''
|
||||
${pkgs.taskwarrior}/bin/task calendar
|
||||
${pkgs.taskwarrior}/bin/task calendar_report
|
||||
'')
|
||||
|
||||
vit
|
||||
(pkgs.writers.writeBashBin "active" "${vit}/bin/vit active")
|
||||
(pkgs.writers.writeBashBin "todo" "${vit}/bin/vit todo")
|
||||
|
||||
taskwarrior-hooks
|
||||
vdirsyncer
|
||||
khal
|
||||
(pkgs.writers.writeBashBin "kalendar" ''
|
||||
${pkgs.vdirsyncer}/bin/vdirsyncer sync
|
||||
${pkgs.khal}/bin/ikhal
|
||||
'')
|
||||
|
||||
python3Packages.bugwarrior
|
||||
|
||||
# bugwarrior
|
||||
#(let
|
||||
# mypython = let
|
||||
# packageOverrides = self: super: {
|
||||
# bugwarrior = super.bugwarrior.overridePythonAttrs (old: {
|
||||
# propagatedBuildInputs = old.propagatedBuildInputs
|
||||
# ++ [ super.setuptools ];
|
||||
# });
|
||||
# };
|
||||
# in pkgs.python3.override { inherit packageOverrides; };
|
||||
#in mypython.pkgs.bugwarrior)
|
||||
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
180
nixos/modules/programs/urxvt.nix
Normal file
180
nixos/modules/programs/urxvt.nix
Normal file
|
@ -0,0 +1,180 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.urxvt;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.urxvt = {
|
||||
|
||||
enable = mkEnableOption "configure and enable urxvt";
|
||||
|
||||
fontSize = mkOption {
|
||||
type = types.int;
|
||||
default = 17;
|
||||
description = ''
|
||||
size of the terminal font
|
||||
'';
|
||||
};
|
||||
|
||||
colorTheme = mkOption {
|
||||
type = types.enum [ "dark" "light" ];
|
||||
default = "dark";
|
||||
description = ''
|
||||
solarized color theme
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ pkgs.rxvt_unicode ];
|
||||
|
||||
environment.etc = {
|
||||
|
||||
"X11/Xresource.d/urxvt".source = pkgs.writeText "Xresource-urxvt" ''
|
||||
!! Perl extensions
|
||||
!! ---------------
|
||||
URxvt.perl-ext-common: default,matcher
|
||||
|
||||
! Urgency
|
||||
URxvt.urgentOnBell: true
|
||||
|
||||
!! Highlight URLs
|
||||
!! --------------
|
||||
URxvt.url-launcher: /run/current-system/sw/bin/browser-select
|
||||
URxvt.matcher.button: 1
|
||||
|
||||
!! History
|
||||
!! -------
|
||||
URxvt.scrollStyle: rxvt
|
||||
URxvt.scrollBar: false
|
||||
URxvt.saveLines: 1000000
|
||||
|
||||
!! Color Configuration
|
||||
!! -------------------
|
||||
|
||||
!! do not graded out unselected shells
|
||||
!! -----------------------------------
|
||||
URxvt.fading: 0
|
||||
'';
|
||||
|
||||
"X11/Xresource.d/urxvt-font".source = let
|
||||
fontFamily = "terminus";
|
||||
normalFont = fontSize:
|
||||
"-*-${fontFamily}-medium-*-*-*-${toString fontSize}-*-*-*-*-*-*-*";
|
||||
boldFont = fontSize:
|
||||
"-*-${fontFamily}-bold-*-*-*-${toString fontSize}-*-*-*-*-*-*-*";
|
||||
italicFont = normalFont;
|
||||
itallicBoldFont = boldFont;
|
||||
backupFont = fontSize:
|
||||
"xft:TerminessTTF Nerd Font:pixelsize=${toString fontSize}";
|
||||
|
||||
fontCommand = key: fontSize: ''
|
||||
URxvt.keysym.M-${key}: command:\033]710;${normalFont fontSize},${
|
||||
backupFont fontSize
|
||||
}\007\033]711;${boldFont fontSize},${backupFont fontSize}\007
|
||||
'';
|
||||
|
||||
in pkgs.writeText "Xresource-urxvt-font" ''
|
||||
|
||||
URxvt.allow_bold: true
|
||||
URxvt.xftAntialias: true
|
||||
|
||||
!! use xfontsel or fontmatrix to choose line
|
||||
!URxvt.font: ${normalFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
!URxvt.boldFont: ${boldFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
!URxvt.italicFont: ${italicFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
!URxvt.bolditalicFont: ${itallicBoldFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
|
||||
URxvt.font: ${normalFont cfg.fontSize}
|
||||
URxvt.boldFont: ${boldFont cfg.fontSize}
|
||||
URxvt.italicFont: ${italicFont cfg.fontSize}
|
||||
URxvt.bolditalicFont: ${itallicBoldFont cfg.fontSize}
|
||||
|
||||
${fontCommand "F1" cfg.fontSize}
|
||||
${fontCommand "F2" (cfg.fontSize + 5)}
|
||||
${fontCommand "F3" (cfg.fontSize + 10)}
|
||||
${fontCommand "F4" (cfg.fontSize + 20)}
|
||||
'';
|
||||
|
||||
"X11/Xresource.d/urxvt-colors".source = let
|
||||
colorTheme = if (cfg.colorTheme == "dark") then ''
|
||||
#define S_base03 #002b36
|
||||
#define S_base02 #073642
|
||||
#define S_base01 #586e75
|
||||
#define S_base00 #657b83
|
||||
#define S_base0 #839496
|
||||
#define S_base1 #93a1a1
|
||||
#define S_base2 #eee8d5
|
||||
#define S_base3 #fdf6e3
|
||||
'' else ''
|
||||
#define S_base03 #fdf6e3
|
||||
#define S_base02 #eee8d5
|
||||
#define S_base01 #93a1a1
|
||||
#define S_base00 #839496
|
||||
#define S_base0 #657b83
|
||||
#define S_base1 #586e75
|
||||
#define S_base2 #073642
|
||||
#define S_base3 #002b36
|
||||
'';
|
||||
|
||||
in pkgs.writeText "Xresource-urxvt-colors" ''
|
||||
|
||||
!! Common
|
||||
!! ------
|
||||
#define S_yellow #b58900
|
||||
#define S_orange #cb4b16
|
||||
#define S_red #dc322f
|
||||
#define S_magenta #d33682
|
||||
#define S_violet #6c71c4
|
||||
#define S_blue #268bd2
|
||||
#define S_cyan #2aa198
|
||||
#define S_green #859900
|
||||
|
||||
!! ColorTheme
|
||||
!! ----------
|
||||
${colorTheme}
|
||||
|
||||
URxvt*background: S_base03
|
||||
URxvt*foreground: S_base0
|
||||
URxvt*fading: 40
|
||||
URxvt*fadeColor: S_base03
|
||||
URxvt*cursorColor: S_base1
|
||||
URxvt*pointerColorBackground: S_base01
|
||||
URxvt*pointerColorForeground: S_base1
|
||||
|
||||
URxvt*color0: S_base02
|
||||
URxvt*color1: S_red
|
||||
URxvt*color2: S_green
|
||||
URxvt*color3: S_yellow
|
||||
URxvt*color4: S_blue
|
||||
URxvt*color5: S_magenta
|
||||
URxvt*color6: S_cyan
|
||||
URxvt*color7: S_base2
|
||||
URxvt*color9: S_orange
|
||||
URxvt*color8: S_base03
|
||||
URxvt*color10: S_base01
|
||||
URxvt*color11: S_base00
|
||||
URxvt*color12: S_base0
|
||||
URxvt*color13: S_violet
|
||||
URxvt*color14: S_base1
|
||||
URxvt*color15: S_base3
|
||||
'';
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
56
nixos/modules/programs/video.nix
Normal file
56
nixos/modules/programs/video.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.video;
|
||||
|
||||
# show keyboard input on desktop for screencasts
|
||||
screenKey = pkgs.symlinkJoin {
|
||||
name = "screen-keys";
|
||||
paths = let
|
||||
screenKeyScript = { position ? "bottom", size ? "small", ... }:
|
||||
pkgs.writeShellScriptBin "screenkeys-${position}-${size}" # sh
|
||||
''
|
||||
${pkgs.screenkey}/bin/screenkey \
|
||||
--no-detach \
|
||||
--bg-color '#fdf6e3' \
|
||||
--font-color '#073642' \
|
||||
-p ${position} \
|
||||
-s ${size} \
|
||||
"$@"
|
||||
'';
|
||||
in lib.flatten (lib.flip map [ "large" "small" "medium" ] (size:
|
||||
lib.flip map [ "top" "center" "bottom" ]
|
||||
(position: screenKeyScript { inherit size position; })));
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.video.enable = mkEnableOption "enable video tools";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
youtube-dl
|
||||
mplayer
|
||||
mpv
|
||||
|
||||
# to record your screen
|
||||
# ---------------------
|
||||
simplescreenrecorder
|
||||
screenKey
|
||||
|
||||
# to transcode video material
|
||||
# ---------------------------
|
||||
handbrake
|
||||
ffmpeg-full
|
||||
|
||||
# video editing
|
||||
# -------------
|
||||
openshot-qt
|
||||
|
||||
];
|
||||
};
|
||||
}
|
||||
|
224
nixos/modules/programs/vim.nix
Normal file
224
nixos/modules/programs/vim.nix
Normal file
|
@ -0,0 +1,224 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.vim;
|
||||
|
||||
nix-xptemplates = pkgs.writeTextFile {
|
||||
name = "nix-xptemplates";
|
||||
destination = "/ftplugin/nix/nix.xpt.vim";
|
||||
text = # vim
|
||||
''
|
||||
XPTemplate priority=personal
|
||||
|
||||
XPT option " tips
|
||||
`name^ = mkOption {
|
||||
type = with types; `type^;
|
||||
description = ${"''"}
|
||||
`cursor^
|
||||
${"''"};
|
||||
};
|
||||
|
||||
XPT package " tips
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT terranix" tips
|
||||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.`name^;
|
||||
in {
|
||||
|
||||
options.`name^ = mkOption {
|
||||
default = {};
|
||||
type = with types; attrsOf (submodule ({ name, ... }:{
|
||||
options = {
|
||||
enable = mkEnableOption "`name^.name";
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
allConfigs = cfg
|
||||
in
|
||||
mkIf (cfg != {} ){
|
||||
`cursor^
|
||||
};
|
||||
}
|
||||
|
||||
XPT module " tips
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.`name^;
|
||||
|
||||
in {
|
||||
|
||||
options.`name^ = {
|
||||
enable = mkEnableOption "enable `name^";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
`cursor^
|
||||
};
|
||||
}
|
||||
|
||||
XPT shell " tips
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
pkgs.mkShell {
|
||||
|
||||
# needed pkgs
|
||||
# -----------
|
||||
buildInputs = with pkgs; [
|
||||
`name^
|
||||
];
|
||||
|
||||
# run this on start
|
||||
# -----------------
|
||||
shellHook = ${"''"}
|
||||
HISTFILE=${"$"}{toString ./.}/.history
|
||||
${"''"};
|
||||
}
|
||||
|
||||
XPT fhsUser " tips
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
(pkgs.buildFHSUserEnv {
|
||||
name = "fhs-user-env";
|
||||
|
||||
targetPkgs = pkgs: with pkgs; [
|
||||
# core stuff
|
||||
# ----------
|
||||
vim silver-searcher curl coreutils git tig
|
||||
|
||||
# common X dependencies
|
||||
# ---------------------
|
||||
atk cairo dbus eudev expat fontconfig freetype gdk_pixbuf glib gnome3.GConf gtk2-x11
|
||||
mesa_glu nspr nss pango xlibs.libXScrnSaver xlibs.libXcomposite xlibs.libXcursor
|
||||
xlibs.libXdamage xlibs.libXfixes xlibs.libXi xlibs.libXrender xlibs.libXtst xorg.libX11
|
||||
xorg.libXext xorg.libXinerama xorg.libxcb
|
||||
liblo zlib fftw minixml libcxx alsaLib glibc
|
||||
|
||||
# new stuff
|
||||
# ---------
|
||||
`cursor^
|
||||
|
||||
];
|
||||
|
||||
# multilib packages
|
||||
# -----------------
|
||||
# these are packages compiled 32bit and 64bit
|
||||
multiPkgs = pkgs: with pkgs; [
|
||||
];
|
||||
|
||||
# environment variables
|
||||
# ---------------------
|
||||
profile = ${"''"}
|
||||
export TERM="xterm"
|
||||
${"''"};
|
||||
|
||||
}).env
|
||||
|
||||
'';
|
||||
};
|
||||
|
||||
# active plugins
|
||||
# --------------
|
||||
extra-runtimepath = with pkgs;
|
||||
lib.concatMapStringsSep "," (pkg: "${pkg.rtp}") [
|
||||
vimPlugins.Syntastic
|
||||
vimPlugins.ack-vim
|
||||
vimPlugins.airline
|
||||
vimPlugins.vim-nix
|
||||
vimPlugins.xptemplate
|
||||
];
|
||||
|
||||
# the vimrc
|
||||
# ---------
|
||||
vimrc = pkgs.writeText "vimrc" ''
|
||||
|
||||
" turn on linenumbers
|
||||
" to turn of :set nonumber
|
||||
:set number
|
||||
|
||||
" show Trailing Whitespaces
|
||||
:set list listchars=tab:»·,trail:¶
|
||||
|
||||
" Map leader is the key for shortcuts
|
||||
nnoremap <SPACE> <Nop>
|
||||
let mapleader = "\<Space>"
|
||||
|
||||
" move blocks of text in visual mode
|
||||
" does not work correctly
|
||||
vmap <up> xkP`[V`]
|
||||
vmap <down> xp`[V`]
|
||||
|
||||
" search/grep case insensitive
|
||||
:set ignorecase
|
||||
|
||||
" tabs should always be 2 spaces
|
||||
set et ts=2 sts=2 sw=2
|
||||
|
||||
" installed vim-plugins
|
||||
set runtimepath=${extra-runtimepath},$VIMRUNTIME,$HOME/.vim,${nix-xptemplates}
|
||||
|
||||
" syntax highlighting on
|
||||
syntax on
|
||||
|
||||
" xptemplates
|
||||
" -----------
|
||||
" a plugin to insert snippets on demand
|
||||
set nocompatible
|
||||
filetype plugin on
|
||||
|
||||
" enable cursor cross
|
||||
" -------------------
|
||||
":hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
|
||||
":hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
|
||||
:hi CursorLine cterm=NONE ctermbg=0 guibg=#073642
|
||||
:hi CursorColumn cterm=NONE ctermbg=0 guibg=#073642
|
||||
set cursorline
|
||||
set cursorcolumn
|
||||
|
||||
" save view
|
||||
" ---------
|
||||
augroup AutoSaveFolds
|
||||
autocmd!
|
||||
autocmd BufWinLeave * mkview
|
||||
autocmd BufWinEnter * silent loadview
|
||||
augroup END
|
||||
|
||||
" some language stuff
|
||||
" -------------------
|
||||
:map <leader>s :setlocal spell spelllang=en
|
||||
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
# no options
|
||||
options.programs.custom.vim.enable = lib.mkEnableOption "vim";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# create vimrc
|
||||
# ------------
|
||||
# and load it as config for vim
|
||||
environment.variables.VIMINIT = ":so /etc/vimrc";
|
||||
environment.etc.vimrc.source = vimrc;
|
||||
|
||||
# set vim to the default editor
|
||||
# -----------------------------
|
||||
programs.vim.defaultEditor = true;
|
||||
|
||||
# install vim
|
||||
# -----------
|
||||
environment.systemPackages = [ pkgs.vim ];
|
||||
};
|
||||
|
||||
}
|
151
nixos/modules/programs/xterm.nix
Normal file
151
nixos/modules/programs/xterm.nix
Normal file
|
@ -0,0 +1,151 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.custom.xterm;
|
||||
|
||||
in {
|
||||
|
||||
options.programs.custom.xterm = {
|
||||
enable = mkEnableOption "configure and enable urxvt";
|
||||
fontSize = mkOption {
|
||||
type = types.int;
|
||||
default = 17;
|
||||
description = ''
|
||||
size of the terminal font
|
||||
'';
|
||||
};
|
||||
colorTheme = mkOption {
|
||||
type = types.enum [ "dark" "light" ];
|
||||
default = "dark";
|
||||
description = ''
|
||||
solarized color theme
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ pkgs.xterm ];
|
||||
|
||||
environment.etc = {
|
||||
|
||||
"X11/Xresource.d/xterm".source = pkgs.writeText "Xresource-xterm" ''
|
||||
|
||||
XTerm*termName: xterm-256color
|
||||
XTerm*selectToClipboard: true
|
||||
|
||||
XTerm.*.bellIsUrgent: true
|
||||
|
||||
'';
|
||||
|
||||
"X11/Xresource.d/xterm-font".source = let
|
||||
fontFamily = "terminus";
|
||||
normalFont = fontSize:
|
||||
"-*-${fontFamily}-medium-*-*-*-${toString fontSize}-*-*-*-*-*-*-*";
|
||||
boldFont = fontSize:
|
||||
"-*-${fontFamily}-bold-*-*-*-${toString fontSize}-*-*-*-*-*-*-*";
|
||||
italicFont = normalFont;
|
||||
itallicBoldFont = boldFont;
|
||||
backupFont = fontSize:
|
||||
"xft:TerminessTTF Nerd Font:pixelsize=${toString fontSize}";
|
||||
in pkgs.writeText "Xresource-xterm-font" ''
|
||||
|
||||
XTerm.allow_bold: true
|
||||
XTerm.xftAntialias: true
|
||||
|
||||
!! use xfontsel or fontmatrix to choose line
|
||||
!XTerm.*.font: ${normalFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
!XTerm.*.boldFont: ${boldFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
!XTerm.*.italicFont: ${italicFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
!XTerm.*.bolditalicFont: ${itallicBoldFont cfg.fontSize},${
|
||||
backupFont cfg.fontSize
|
||||
}
|
||||
|
||||
XTerm.*.font: ${normalFont cfg.fontSize}
|
||||
XTerm.*.boldFont: ${boldFont cfg.fontSize}
|
||||
XTerm.*.italicFont: ${italicFont cfg.fontSize}
|
||||
XTerm.*.bolditalicFont: ${itallicBoldFont cfg.fontSize}
|
||||
'';
|
||||
|
||||
"X11/Xresource.d/xterm-colors".source = let
|
||||
colorTheme = if (cfg.colorTheme == "dark") then ''
|
||||
#define S_base03 #002b36
|
||||
#define S_base02 #073642
|
||||
#define S_base01 #586e75
|
||||
#define S_base00 #657b83
|
||||
#define S_base0 #839496
|
||||
#define S_base1 #93a1a1
|
||||
#define S_base2 #eee8d5
|
||||
#define S_base3 #fdf6e3
|
||||
|
||||
'' else ''
|
||||
#define S_base03 #fdf6e3
|
||||
#define S_base02 #eee8d5
|
||||
#define S_base01 #93a1a1
|
||||
#define S_base00 #839496
|
||||
#define S_base0 #657b83
|
||||
#define S_base1 #586e75
|
||||
#define S_base2 #073642
|
||||
#define S_base3 #002b36
|
||||
'';
|
||||
|
||||
in pkgs.writeText "Xresource-xterm-colors" ''
|
||||
|
||||
!! Color Configuration
|
||||
!! -------------------
|
||||
|
||||
!! Common
|
||||
!! ------
|
||||
#define S_yellow #b58900
|
||||
#define S_orange #cb4b16
|
||||
#define S_red #dc322f
|
||||
#define S_magenta #d33682
|
||||
#define S_violet #6c71c4
|
||||
#define S_blue #268bd2
|
||||
#define S_cyan #2aa198
|
||||
#define S_green #859900
|
||||
|
||||
!! ColorTheme
|
||||
!! ----------
|
||||
${colorTheme}
|
||||
|
||||
XTerm*background: S_base03
|
||||
XTerm*foreground: S_base0
|
||||
XTerm*fading: 40
|
||||
XTerm*fadeColor: S_base03
|
||||
XTerm*cursorColor: S_base1
|
||||
XTerm*pointerColorBackground: S_base01
|
||||
XTerm*pointerColorForeground: S_base1
|
||||
|
||||
XTerm*color0: S_base02
|
||||
XTerm*color1: S_red
|
||||
XTerm*color2: S_green
|
||||
XTerm*color3: S_yellow
|
||||
XTerm*color4: S_blue
|
||||
XTerm*color5: S_magenta
|
||||
XTerm*color6: S_cyan
|
||||
XTerm*color7: S_base2
|
||||
XTerm*color9: S_orange
|
||||
XTerm*color8: S_base03
|
||||
XTerm*color10: S_base01
|
||||
XTerm*color11: S_base00
|
||||
XTerm*color12: S_base0
|
||||
XTerm*color13: S_violet
|
||||
XTerm*color14: S_base1
|
||||
XTerm*color15: S_base3
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
97
nixos/modules/services/castget.nix
Normal file
97
nixos/modules/services/castget.nix
Normal file
|
@ -0,0 +1,97 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.custom.services.castget;
|
||||
|
||||
in {
|
||||
|
||||
options.custom.services.castget = {
|
||||
enable = mkEnableOption "enable custom.services.castget";
|
||||
feeds = mkOption {
|
||||
type = with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
url = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
url to the rss feed
|
||||
'';
|
||||
};
|
||||
spool = mkOption {
|
||||
type = with types; path;
|
||||
description = ''
|
||||
download enclosures to this directory.
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
description = ''
|
||||
configurations for the cast
|
||||
'';
|
||||
};
|
||||
user = mkOption {
|
||||
type = with types; string;
|
||||
description = ''
|
||||
user to run the systemd service as
|
||||
'';
|
||||
};
|
||||
timerConfig = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
default = { OnCalendar = "daily"; };
|
||||
example = {
|
||||
OnCalendar = "00:05";
|
||||
RandomizedDelaySec = "5h";
|
||||
};
|
||||
description = ''
|
||||
When to run the polling script. See man systemd.timer for details.
|
||||
'';
|
||||
};
|
||||
serviceName = mkOption {
|
||||
type = with types; string;
|
||||
default = "castget";
|
||||
description = ''
|
||||
the name of the castget systemd service
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
systemd.services."${cfg.serviceName}" = {
|
||||
description = "castget polling service";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
restartIfChanged = false;
|
||||
serviceConfig.User = cfg.user;
|
||||
|
||||
preStart = let
|
||||
mkSpools =
|
||||
mapAttrsToList (ignore: value: "mkdir -p ${value.spool}") cfg.feeds;
|
||||
in concatStringsSep "\n" mkSpools;
|
||||
script = let
|
||||
channels = mapAttrsToList (key: ignore: key) cfg.feeds;
|
||||
castget = "${pkgs.castget}/bin/castget";
|
||||
|
||||
configurationFile = let
|
||||
configurations = mapAttrsToList (key: value: ''
|
||||
[${key}]
|
||||
url=${value.url}
|
||||
spool=${value.spool}
|
||||
'') cfg.feeds;
|
||||
in (pkgs.writeText "castget-configuration"
|
||||
(concatStringsSep "" configurations));
|
||||
in (concatMapStringsSep "\n"
|
||||
(channel: "${castget} --rcfile ${configurationFile} ${channel}")
|
||||
channels);
|
||||
};
|
||||
|
||||
systemd.timers."${cfg.serviceName}" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = cfg.timerConfig;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
37
nixos/modules/services/home-assistant.nix
Normal file
37
nixos/modules/services/home-assistant.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.homeAssistantConfig;
|
||||
|
||||
mkMagicMergeOption = { description ? "", example ? { }, default ? { }, ... }:
|
||||
mkOption {
|
||||
inherit example description default;
|
||||
type = with lib.types;
|
||||
let
|
||||
valueType = nullOr (oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
]) // {
|
||||
description = "";
|
||||
emptyValue.value = { };
|
||||
};
|
||||
in valueType;
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
options.services.homeAssistantConfig = mkMagicMergeOption {
|
||||
description = ''
|
||||
home-assistant configuration
|
||||
'';
|
||||
};
|
||||
|
||||
config = mkIf (cfg != null) { services.home-assistant.config = cfg; };
|
||||
}
|
180
nixos/modules/services/lektor.nix
Normal file
180
nixos/modules/services/lektor.nix
Normal file
|
@ -0,0 +1,180 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.lektor;
|
||||
|
||||
in {
|
||||
|
||||
options.services.lektor = {
|
||||
enable = mkEnableOption "enable services.lektor";
|
||||
user = mkOption {
|
||||
default = "lektor";
|
||||
type = with types; str;
|
||||
description = ''
|
||||
name of the lektor service
|
||||
'';
|
||||
};
|
||||
home = mkOption {
|
||||
default = "/home/${cfg.user}";
|
||||
type = with types; str;
|
||||
description = ''
|
||||
home of the service
|
||||
'';
|
||||
};
|
||||
repository = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
Repository to get the lektor project from.
|
||||
'';
|
||||
example = "git@github.com:lektor/lektor-website.git";
|
||||
};
|
||||
bind = mkOption {
|
||||
default = "0.0.0.0";
|
||||
type = with types; str;
|
||||
description = ''
|
||||
Host to bind the lektor service to.
|
||||
'';
|
||||
};
|
||||
serviceName = mkOption {
|
||||
default = "lektor";
|
||||
type = with types; str;
|
||||
description = ''
|
||||
name of the system service (without the .service suffix)
|
||||
'';
|
||||
};
|
||||
port = mkOption {
|
||||
default = 5000;
|
||||
type = with types; int;
|
||||
description = ''
|
||||
Port to bind the lektor service to.
|
||||
'';
|
||||
};
|
||||
additionalScript = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr path;
|
||||
description = ''
|
||||
A script you can us as a hook before the lektor server start
|
||||
(for example to creat your css or javascript files)
|
||||
'';
|
||||
example = pkgs.writeShellScript "build" ''
|
||||
${pkgs.nix}/bin/nix-shell --run build";
|
||||
'';
|
||||
};
|
||||
#sshMatchBlocks = mkOption {
|
||||
# default = [];
|
||||
# type = with types; listOf attrs;
|
||||
# description = ''
|
||||
# a matchBlock from home-manager.users.<name>.programs.ssh.matchBlocks;
|
||||
# '';
|
||||
#};
|
||||
host = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
ssh host to pull from and push to
|
||||
'';
|
||||
};
|
||||
sshKey = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
todo : avoid this, or make sure the home folder is crypted
|
||||
Warning the key will be copied into the home folder of the user
|
||||
ssh key to use
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# create User
|
||||
users.users."${cfg.user}" = {
|
||||
home = cfg.home;
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
# create systemd service to start service
|
||||
systemd.services."${cfg.serviceName}" = {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment.NIX_PATH = config.environment.variables.NIX_PATH;
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
# todo : this is not working properly
|
||||
TimeoutStartSec =
|
||||
"infinity"; # it might take some time will this thing is up
|
||||
|
||||
ExecStartPre = let
|
||||
|
||||
sshKeyTarget = "/run/keys.lektor/id_rsa";
|
||||
|
||||
sshConfig = pkgs.writeText "sshconfig" ''
|
||||
Host ${cfg.host}
|
||||
IdentityFile ${sshKeyTarget}
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
Compression no
|
||||
ServerAliveInterval 0
|
||||
HashKnownHosts no
|
||||
UserKnownHostsFile ~/.ssh/known_hosts
|
||||
ControlMaster no
|
||||
ControlPath ~/.ssh/master-%r@%n:%p
|
||||
ControlPersist no
|
||||
'';
|
||||
|
||||
sshKeyScript = pkgs.writers.writeDash "keyfile-gen" # sh
|
||||
''
|
||||
set -x
|
||||
|
||||
# setup ~/.ssh
|
||||
mkdir -p ${cfg.home}/.ssh
|
||||
chown ${cfg.user} ${cfg.home}/.ssh
|
||||
chmod 700 ${cfg.home}/.ssh
|
||||
|
||||
cp ${sshConfig} ${cfg.home}/.ssh/config
|
||||
chown ${cfg.user} ${cfg.home}/.ssh/config
|
||||
chmod 500 ${cfg.home}/.ssh/config
|
||||
|
||||
mkdir -p ${dirOf sshKeyTarget}
|
||||
chmod 700 ${dirOf sshKeyTarget}
|
||||
chown ${cfg.user} ${dirOf sshKeyTarget}
|
||||
cp ${toString cfg.sshKey} ${sshKeyTarget}
|
||||
chown ${cfg.user} ${sshKeyTarget}
|
||||
chmod 500 ${sshKeyTarget}
|
||||
'';
|
||||
|
||||
cloneScript = pkgs.writers.writeDash "clone" # sh
|
||||
''
|
||||
set -x
|
||||
if [[ `ls ~/${cfg.user} | wc -l` == 0 ]]
|
||||
then
|
||||
rm ~/${cfg.user}
|
||||
fi
|
||||
${pkgs.git}/bin/git clone ${cfg.repository} ~/${cfg.user}
|
||||
'';
|
||||
|
||||
in [ "+${sshKeyScript}" "-${cloneScript}" ];
|
||||
};
|
||||
|
||||
# todo : add restart ruling
|
||||
|
||||
script = # sh
|
||||
''
|
||||
cd ~/${cfg.user} && \
|
||||
${pkgs.git}/bin/git pull && \
|
||||
${
|
||||
optionalString (cfg.additionalScript != null)
|
||||
"${cfg.additionalScript} &&"
|
||||
} \
|
||||
${pkgs.python36Packages.lektor}/bin/lektor server \
|
||||
--host ${cfg.bind} \
|
||||
--port ${toString cfg.port}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
52
nixos/modules/services/light-control.nix
Normal file
52
nixos/modules/services/light-control.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.mqtt.light-control;
|
||||
|
||||
mkMagicMergeOption = { description ? "", example ? { }, default ? { }, ... }:
|
||||
mkOption {
|
||||
inherit example description default;
|
||||
type = with lib.types;
|
||||
let
|
||||
valueType = nullOr (oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
]) // {
|
||||
description = "";
|
||||
emptyValue.value = { };
|
||||
};
|
||||
in valueType;
|
||||
};
|
||||
|
||||
lightControlConfig =
|
||||
pkgs.writeText "light-control.json" (builtins.toJSON cfg.config);
|
||||
|
||||
in {
|
||||
|
||||
options.services.mqtt.light-control = {
|
||||
enable = mkEnableOption "enable mqtt.light-control";
|
||||
loglevel = mkOption {
|
||||
default = "info";
|
||||
type = with types; enum [ "info" "trace" "debug" "error" "warning" ];
|
||||
};
|
||||
config =
|
||||
mkMagicMergeOption { description = "configuration of light-control"; };
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services."light-control" = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = { RUST_LOG = "light_control=${cfg.loglevel}"; };
|
||||
script = ''
|
||||
${pkgs.light-control}/bin/light-control ${lightControlConfig}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
101
nixos/modules/services/samba-share.nix
Normal file
101
nixos/modules/services/samba-share.nix
Normal file
|
@ -0,0 +1,101 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.custom.samba-share;
|
||||
|
||||
in {
|
||||
|
||||
options.custom.samba-share = {
|
||||
enable = mkEnableOption "enable custom.samba-share";
|
||||
folders = mkOption {
|
||||
default = { };
|
||||
type = with types; attrsOf str;
|
||||
description = ''
|
||||
folders to share as readonly
|
||||
'';
|
||||
example = { public = "/srv/downloads/movies"; };
|
||||
};
|
||||
private = mkOption {
|
||||
default = { };
|
||||
type = with types;
|
||||
attrsOf (submodule {
|
||||
options = {
|
||||
users = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
System users allowed to access the folder.
|
||||
To set password:
|
||||
# nix-shell -p samba
|
||||
# smbpasswd -a <user>
|
||||
'';
|
||||
};
|
||||
folder = mkOption { type = with types; str; };
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
|
||||
(mkIf cfg.enable {
|
||||
|
||||
networking.firewall.enable = true;
|
||||
networking.firewall.allowPing = true;
|
||||
networking.firewall.allowedTCPPorts = [ 445 139 ];
|
||||
networking.firewall.allowedUDPPorts = [ 137 138 ];
|
||||
|
||||
services.samba = {
|
||||
enable = true;
|
||||
# services.samba.securityType = "share";
|
||||
extraConfig = ''
|
||||
guest account = smbguest
|
||||
map to guest = bad user
|
||||
|
||||
# disable printing
|
||||
load printers = no
|
||||
printing = bsd
|
||||
printcap name = /dev/null
|
||||
disable spoolss = yes
|
||||
'';
|
||||
|
||||
shares = mapAttrs' (name: path: {
|
||||
name = name;
|
||||
value = {
|
||||
browsable = "yes";
|
||||
comment = "read only share ${name}";
|
||||
path = path;
|
||||
"read only" = "yes";
|
||||
"guest ok" = "yes";
|
||||
};
|
||||
}) cfg.folders // (mapAttrs' (name:
|
||||
{ users, folder, ... }: {
|
||||
name = name;
|
||||
value = {
|
||||
browsable = "yes";
|
||||
comment = "read only share ${name}";
|
||||
path = folder;
|
||||
"read only" = "no";
|
||||
"valid users" = users;
|
||||
"guest ok" = "false";
|
||||
};
|
||||
}) cfg.private);
|
||||
};
|
||||
|
||||
users.users.smbguest = {
|
||||
name = "smbguest";
|
||||
uid = config.ids.uids.smbguest;
|
||||
description = "smb guest user";
|
||||
home = "/home/smbguest";
|
||||
createHome = true;
|
||||
};
|
||||
|
||||
})
|
||||
# todo : maybe better to have a parameter for this
|
||||
(mkIf config.services.syncthing.enable {
|
||||
users.groups."syncthing".members = [ "smbguest" ];
|
||||
})
|
||||
];
|
||||
}
|
60
nixos/modules/services/sshd.nix
Normal file
60
nixos/modules/services/sshd.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.custom.ssh;
|
||||
|
||||
in {
|
||||
|
||||
options.services.custom.ssh = {
|
||||
tools.enable = mkEnableOption "Add ssh tools";
|
||||
sshd = {
|
||||
enable = mkEnableOption "Start sshd server";
|
||||
rootKeyFiles = mkOption {
|
||||
type = with types; listOf path;
|
||||
description = "keys to root login";
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
|
||||
(mkIf cfg.tools.enable {
|
||||
environment.systemPackages = with pkgs;
|
||||
[
|
||||
# sshuttle
|
||||
sshfs
|
||||
];
|
||||
})
|
||||
|
||||
(mkIf cfg.sshd.enable {
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
forwardX11 = true;
|
||||
passwordAuthentication = false;
|
||||
};
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keyFiles = cfg.sshd.rootKeyFiles;
|
||||
|
||||
services.openssh.extraConfig = ''
|
||||
Banner /etc/sshd/banner-line
|
||||
'';
|
||||
|
||||
environment.etc."sshd/banner-line".text = let
|
||||
text = config.networking.hostName;
|
||||
size = 80 - (lib.stringLength text);
|
||||
space = lib.fixedWidthString size " " "";
|
||||
in ''
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
${space}${text}
|
||||
'';
|
||||
|
||||
})
|
||||
|
||||
];
|
||||
|
||||
}
|
107
nixos/modules/services/videoencoder.nix
Normal file
107
nixos/modules/services/videoencoder.nix
Normal file
|
@ -0,0 +1,107 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.service.videoencoder;
|
||||
|
||||
# todo : escape output and input File
|
||||
createEncoder = tmpFolder: inputFile: outputFile: # sh
|
||||
''
|
||||
mkdir -p ${tmpFolder}
|
||||
rm -rf ${tmpFolder}/*
|
||||
TMP_FILE=`mktemp --dry-run ${tmpFolder}/XXXXXXXX.${cfg.format}`
|
||||
|
||||
if [ ! -f "${outputFile}" ]
|
||||
then
|
||||
${pkgs.ffmpeg}/bin/ffmpeg \
|
||||
-i "${inputFile}" \
|
||||
-filter:v scale=h='min(720\,ih)':w='min(1280\,iw)' \
|
||||
-vcodec libx264 \
|
||||
-preset veryslow \
|
||||
-profile:v ${cfg.profile} \
|
||||
${optionalString (cfg.tune != null) "-tune ${cfg.tune}"} \
|
||||
-acodec aac \
|
||||
"$TMP_FILE" \
|
||||
-hide_banner \
|
||||
&& cp $TMP_FILE "${outputFile}.${cfg.format}" \
|
||||
&& rm $TMP_FILE
|
||||
fi
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
options.service.videoencoder = {
|
||||
enable = mkEnableOption "enable service.videoencoder";
|
||||
|
||||
profile = mkOption {
|
||||
type = with types; string;
|
||||
default = "main";
|
||||
description = ''
|
||||
-profile:v
|
||||
'';
|
||||
};
|
||||
|
||||
tune = mkOption {
|
||||
type = with types;
|
||||
nullOr (enum [ "film" "animation" "grain" "stillimage" ]);
|
||||
default = null;
|
||||
description = ''
|
||||
-tune
|
||||
'';
|
||||
};
|
||||
|
||||
format = mkOption {
|
||||
type = with types; enum [ "mp4" "mkv" ];
|
||||
default = "mp4";
|
||||
description = ''
|
||||
the format
|
||||
'';
|
||||
};
|
||||
|
||||
fileConfig = mkOption {
|
||||
type = with types;
|
||||
listOf (submodule {
|
||||
options = {
|
||||
inputFile = mkOption {
|
||||
# todo make this path
|
||||
type = with types; string;
|
||||
description = ''
|
||||
full path to the inputFile
|
||||
'';
|
||||
};
|
||||
outputFile = mkOption {
|
||||
type = with types; string;
|
||||
description = ''
|
||||
full path to the ouputFile
|
||||
folder must exist
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
description = ''
|
||||
list of files to encode.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
systemd.services."videoEncoding" = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
enable = true;
|
||||
script = let
|
||||
myList = map (value:
|
||||
createEncoder "/tmp/videoencoder" value.inputFile value.outputFile)
|
||||
cfg.fileConfig;
|
||||
in ''
|
||||
set -x
|
||||
${concatStringsSep "\n" myList}
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
170
nixos/modules/system/audio.nix
Normal file
170
nixos/modules/system/audio.nix
Normal file
|
@ -0,0 +1,170 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
ladspaPath = "${pkgs.ladspaPlugins}/lib/ladspa";
|
||||
|
||||
jackScript =
|
||||
pkgs.writeShellScriptBin "jack" (lib.fileContents ../../assets/jack.sh);
|
||||
|
||||
queueElement = {
|
||||
options = {
|
||||
plugin = mkOption {
|
||||
type = with types; str;
|
||||
description = "file name without suffix of the plugin";
|
||||
};
|
||||
label = mkOption {
|
||||
type = with types; str;
|
||||
description = "label of the queue element (needs to be correct)";
|
||||
};
|
||||
control = mkOption {
|
||||
type = with types; listOf str;
|
||||
description = "parameter of plugin";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sinkElement = {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = with types; str;
|
||||
description = "name of the sink";
|
||||
};
|
||||
queue = mkOption {
|
||||
type = with types; listOf (submodule queueElement);
|
||||
description = "queues";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.system.custom.audio;
|
||||
|
||||
in {
|
||||
|
||||
options.system.custom.audio = {
|
||||
enable = mkEnableOption "use PluseAudio";
|
||||
sinks = mkOption {
|
||||
type = with types; listOf (submodule sinkElement);
|
||||
description = "list of sinks";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# add virtual midi module
|
||||
# -----------------------
|
||||
#boot = {
|
||||
# # to route midi signals
|
||||
# # between bitwig and vcvrack
|
||||
# kernelModules = [ "snd_virmidi" ];
|
||||
# # index=-2 prevents from beeing recognised as the default
|
||||
# # audio device
|
||||
# # midi_devs limit the number of midi devices.
|
||||
# extraModprobeConfig = "options snd-virmidi index=-2 midi_devs=1";
|
||||
#};
|
||||
|
||||
# LADSPA
|
||||
# ------
|
||||
programs.bash.interactiveShellInit = # sh
|
||||
''
|
||||
# set ladspa library path
|
||||
# about testing the plugins check analyseplugin command
|
||||
export LADSPA_PATH=${ladspaPath}
|
||||
'';
|
||||
programs.zsh.interactiveShellInit = # sh
|
||||
''
|
||||
# set ladspa library path
|
||||
# about testing the plugins check analyseplugin command
|
||||
export LADSPA_PATH=${ladspaPath}
|
||||
'';
|
||||
|
||||
# PulseAudio
|
||||
# ----------
|
||||
|
||||
# because of systemWide ensure main user is in audio group
|
||||
system.custom.mainUser.extraGroups = [ "audio" ];
|
||||
|
||||
#services.pipewire = {
|
||||
# enable = true;
|
||||
# alsa.enable = true;
|
||||
# jack.enable = true;
|
||||
# media-session.enable = true;
|
||||
# pulse.enable = true;
|
||||
#};
|
||||
|
||||
hardware.pulseaudio = {
|
||||
enable = true;
|
||||
package = pkgs.pulseaudioFull;
|
||||
|
||||
# all in audio group can do audio
|
||||
systemWide = true;
|
||||
|
||||
extraConfig = ''
|
||||
|
||||
# automatically switch to newly-connected devices
|
||||
load-module module-switch-on-connect
|
||||
|
||||
# http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html
|
||||
# https://gavv.github.io/articles/pulseaudio-under-the-hood/#ladspa-plugin-sink
|
||||
${builtins.toString (flip map cfg.sinks (sink: ''
|
||||
# ladspa sink : ${sink.name}
|
||||
# -------------
|
||||
${builtins.toString (flip imap0 (reverseList sink.queue)
|
||||
(index: queua:
|
||||
let
|
||||
sinkName = suffix: "${sink.name}${builtins.toString suffix}";
|
||||
sinkValue = "sink_name=${sinkName index}";
|
||||
sinkDescription = "sink_properties=device.description=${
|
||||
sinkName index
|
||||
}-${queua.label}";
|
||||
masterValue = if (index == 0) then
|
||||
""
|
||||
else
|
||||
"sink_master=${sinkName (index - 1)}";
|
||||
pluginValue = "plugin=${ladspaPath}/${queua.plugin}";
|
||||
labelValue = "label=${queua.label}";
|
||||
controlValue = "control=${
|
||||
builtins.toString
|
||||
(foldl (a: b: "${a},${b}") (head queua.control)
|
||||
(tail queua.control))
|
||||
}";
|
||||
in ''
|
||||
# ${sinkName index} : ${queua.label}
|
||||
load-module module-ladspa-sink ${sinkValue} ${sinkDescription} ${masterValue} ${pluginValue} ${labelValue} ${controlValue}
|
||||
''))}
|
||||
''))}
|
||||
'';
|
||||
};
|
||||
|
||||
# Packages needed
|
||||
# ---------------
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
# Music making
|
||||
# ------------
|
||||
#jackScript
|
||||
#jack2Full
|
||||
#patchage
|
||||
#zynaddsubfx
|
||||
#qjackctl
|
||||
|
||||
alsaUtils
|
||||
|
||||
# LADSPA
|
||||
# ------
|
||||
ladspaPlugins
|
||||
ladspa-sdk
|
||||
|
||||
# PulseAudio control
|
||||
# ------------------
|
||||
pavucontrol
|
||||
lxqt.pavucontrol-qt
|
||||
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
34
nixos/modules/system/bluetooth.nix
Normal file
34
nixos/modules/system/bluetooth.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
cfg = config.system.custom.bluetooth;
|
||||
|
||||
in {
|
||||
|
||||
options.system.custom.bluetooth.enable =
|
||||
lib.mkEnableOption "enable bluetooth support";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
settings.General.AutoConnect = true;
|
||||
};
|
||||
|
||||
services.blueman.enable = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
# bluetooth audio
|
||||
# ---------------
|
||||
# todo : check if pulseaudio is enabled
|
||||
bluez
|
||||
bluez-tools
|
||||
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
76
nixos/modules/system/font.nix
Normal file
76
nixos/modules/system/font.nix
Normal file
|
@ -0,0 +1,76 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.system.custom.fonts;
|
||||
|
||||
in {
|
||||
|
||||
options.system.custom.fonts = {
|
||||
enable = mkEnableOption "enable fonts";
|
||||
dpi = mkOption {
|
||||
type = types.int;
|
||||
default = 141;
|
||||
description = ''
|
||||
dpi of the monitor
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# You can put your private ttf fonts into
|
||||
# in $XDG_DATA_HOME/fonts, which for most users will resolve to ~/.local/share/fonts
|
||||
# see https://nixos.wiki/wiki/Fonts
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
fonts = {
|
||||
|
||||
enableDefaultFonts = true;
|
||||
enableGhostscriptFonts = true;
|
||||
fontDir.enable = true;
|
||||
|
||||
fontconfig = {
|
||||
dpi = cfg.dpi;
|
||||
subpixel = {
|
||||
lcdfilter = "default";
|
||||
rgba = "rgb";
|
||||
};
|
||||
hinting = {
|
||||
enable = true;
|
||||
autohint = false;
|
||||
};
|
||||
enable = true;
|
||||
antialias = true;
|
||||
#defaultFonts = { monospace = [ "inconsolata" ]; };
|
||||
};
|
||||
|
||||
fonts = with pkgs; [
|
||||
|
||||
corefonts
|
||||
hasklig
|
||||
inconsolata
|
||||
source-code-pro
|
||||
symbola
|
||||
ubuntu_font_family
|
||||
|
||||
# symbol fonts
|
||||
# ------------
|
||||
# nerdfonts
|
||||
powerline-fonts
|
||||
font-awesome-ttf
|
||||
fira-code-symbols
|
||||
|
||||
# shell font
|
||||
# ----------
|
||||
terminus_font
|
||||
gohufont
|
||||
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
75
nixos/modules/system/mainUser.nix
Normal file
75
nixos/modules/system/mainUser.nix
Normal file
|
@ -0,0 +1,75 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.system.custom.mainUser;
|
||||
|
||||
dockerGroup =
|
||||
if (config.virtualisation.docker.enable) then [ "docker" ] else [ ];
|
||||
|
||||
vboxGroup = if (config.virtualisation.virtualbox.host.enable) then
|
||||
[ "vboxusers" ]
|
||||
else
|
||||
[ ];
|
||||
|
||||
in {
|
||||
|
||||
options.system.custom.mainUser = {
|
||||
|
||||
enable = mkEnableOption "enable mainUser for a desktop system";
|
||||
|
||||
userName = mkOption {
|
||||
type = with types; str;
|
||||
description = ''
|
||||
name of the main user
|
||||
'';
|
||||
};
|
||||
|
||||
uid = mkOption {
|
||||
type = with types; int;
|
||||
default = 1337;
|
||||
description = ''
|
||||
uid of main user
|
||||
'';
|
||||
};
|
||||
|
||||
extraGroups = mkOption {
|
||||
default = [ ];
|
||||
type = with types; listOf str;
|
||||
description = ''
|
||||
list of groups the main user should also be in
|
||||
'';
|
||||
};
|
||||
|
||||
authorizedKeyFiles = mkOption {
|
||||
default = [ ];
|
||||
type = with types; listOf str;
|
||||
description = ''
|
||||
list of keys allowed to login as this user
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
users = {
|
||||
|
||||
mutableUsers = true;
|
||||
defaultUserShell = pkgs.zsh;
|
||||
|
||||
users.mainUser = {
|
||||
isNormalUser = true;
|
||||
name = cfg.userName;
|
||||
uid = cfg.uid;
|
||||
home = "/home/${cfg.userName}";
|
||||
initialPassword = cfg.userName;
|
||||
extraGroups = [ "wheel" "networkmanager" "transmission" "wireshark" ]
|
||||
++ dockerGroup ++ vboxGroup ++ cfg.extraGroups;
|
||||
openssh.authorizedKeys.keyFiles = cfg.authorizedKeyFiles;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
65
nixos/modules/system/on-failure.nix
Normal file
65
nixos/modules/system/on-failure.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
|
||||
cfg = config.on-failure;
|
||||
|
||||
api = {
|
||||
|
||||
enable = mkEnableOption "krebs.on-failure" // {
|
||||
default = cfg.plans != { };
|
||||
};
|
||||
|
||||
url = mkOption {
|
||||
type = types.str;
|
||||
description = "url on where to send the message to";
|
||||
};
|
||||
|
||||
plans = mkOption {
|
||||
default = { };
|
||||
type = with types;
|
||||
attrsOf (submodule ({ config, ... }: {
|
||||
options = {
|
||||
enable = mkEnableOption "on-failure.${config.name}" // {
|
||||
default = true;
|
||||
};
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = config._module.args.name;
|
||||
description = "Name of the to-be-monitored service.";
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
enabled-plans = filter (getAttr "enable") (attrValues cfg.plans);
|
||||
|
||||
to-services = plan: {
|
||||
"${plan.name}".unitConfig.OnFailure = "on-failure.${plan.name}.service";
|
||||
"on-failure.${plan.name}".serviceConfig = rec {
|
||||
ExecStart = mattermostStart plan;
|
||||
SyslogIdentifier = ExecStart.name;
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
|
||||
# todo this output must be better
|
||||
mattermostStart = plan:
|
||||
pkgs.writers.writeDash "on-failure.${plan.name}" ''
|
||||
${pkgs.curl}/bin/curl \
|
||||
--include \
|
||||
--request POST \
|
||||
--data-urlencode \
|
||||
'payload={"text": "<!channel> :fire: Service Failed ${plan.name} on ${config.networking.hostName}"}' \
|
||||
${cfg.url}
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
options.on-failure = api;
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services = foldl (a: b: a // b) { } (map to-services enabled-plans);
|
||||
};
|
||||
}
|
95
nixos/modules/system/permown.nix
Normal file
95
nixos/modules/system/permown.nix
Normal file
|
@ -0,0 +1,95 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.system.permown;
|
||||
nameGenerator = path: "permown.${replaceStrings [ "/" ] [ "_" ] path}";
|
||||
|
||||
in {
|
||||
|
||||
options.system.permown = mkOption {
|
||||
default = { };
|
||||
type = with types;
|
||||
attrsOf (submodule ({ config, ... }: {
|
||||
options = {
|
||||
directory-mode = mkOption {
|
||||
default = "=rwx";
|
||||
type = types.str;
|
||||
};
|
||||
file-mode = mkOption {
|
||||
default = "=rw";
|
||||
type = types.str;
|
||||
};
|
||||
group = mkOption {
|
||||
apply = x: if x == null then "" else x;
|
||||
default = null;
|
||||
type = types.nullOr types.str;
|
||||
};
|
||||
owner = mkOption { type = types.str; };
|
||||
path = mkOption {
|
||||
default = config._module.args.name;
|
||||
type = types.path;
|
||||
};
|
||||
umask = mkOption {
|
||||
default = "0027";
|
||||
type = types.str;
|
||||
};
|
||||
timer = mkOption {
|
||||
default = "hourly";
|
||||
type = types.str;
|
||||
description =
|
||||
"OnCalendar string on how frequent should this command run";
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
||||
config = let plans = lib.attrValues cfg;
|
||||
|
||||
in mkIf (plans != [ ]) {
|
||||
|
||||
system.activationScripts.permown = let
|
||||
mkdir = { path, ... }: ''
|
||||
${pkgs.coreutils}/bin/mkdir -p ${path}
|
||||
'';
|
||||
in concatMapStrings mkdir plans;
|
||||
|
||||
systemd.services = listToAttrs (flip map plans
|
||||
({ path, directory-mode, file-mode, owner, group, umask, ... }: {
|
||||
name = nameGenerator path;
|
||||
value = {
|
||||
environment = {
|
||||
DIR_MODE = directory-mode;
|
||||
FILE_MODE = file-mode;
|
||||
OWNER_GROUP = "${owner}:${group}";
|
||||
ROOT_PATH = path;
|
||||
};
|
||||
path = [ pkgs.coreutils pkgs.findutils pkgs.inotifyTools ];
|
||||
serviceConfig = {
|
||||
ExecStart = pkgs.writers.writeDash "permown" ''
|
||||
set -efu
|
||||
find "$ROOT_PATH" -exec chown -h "$OWNER_GROUP" {} +
|
||||
find "$ROOT_PATH" -type d -exec chmod "$DIR_MODE" {} +
|
||||
find "$ROOT_PATH" -type f -exec chmod "$FILE_MODE" {} +
|
||||
'';
|
||||
PrivateTmp = true;
|
||||
Restart = "always";
|
||||
RestartSec = 10;
|
||||
UMask = umask;
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
}));
|
||||
|
||||
systemd.timers = listToAttrs (flip map plans ({ path, timer, ... }: {
|
||||
name = nameGenerator path;
|
||||
value = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
timerConfig.OnCalendar = timer;
|
||||
};
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
}
|
86
nixos/modules/system/wifi.nix
Normal file
86
nixos/modules/system/wifi.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.system.custom.wifi;
|
||||
|
||||
in {
|
||||
|
||||
options.system.custom.wifi = {
|
||||
enable = mkEnableOption "enable wifi";
|
||||
system = mkOption {
|
||||
default = "wpa_supplicant";
|
||||
type = with types; enum [ "wpa_supplicant" "networkmanager" ];
|
||||
};
|
||||
configurationFile = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr path;
|
||||
description = ''
|
||||
the target of /etc/wpa_supplicant.conf
|
||||
'';
|
||||
};
|
||||
interfaces = mkOption {
|
||||
type = with types; listOf string;
|
||||
default = [ ];
|
||||
description = ''
|
||||
list of interfaces to take care of,
|
||||
if empty it will test all interfaces
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
|
||||
(mkIf (cfg.enable && cfg.system == "wpa_supplicant") {
|
||||
networking.wireless.enable = true;
|
||||
networking.wireless.interfaces = cfg.interfaces;
|
||||
})
|
||||
|
||||
(mkIf (cfg.enable && cfg.system == "networkmanager") {
|
||||
networking.networkmanager.enable = true;
|
||||
networking.networkmanager.wifi.powersave = true;
|
||||
networking.networkmanager.extraConfig = ''
|
||||
# The number of times a connection activation should be automatically tried
|
||||
# before switching to another one. This value applies only to connections
|
||||
# that can auto-connect and have a connection. autoconnect-retries property set to -1.
|
||||
# If not specified, connections will be tried 4 times.
|
||||
# Setting this value to 1 means to try activation once, without retry.
|
||||
autoconnect-retries-default=999
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf (cfg.enable && cfg.configurationFile != null) {
|
||||
environment.etc."wpa_supplicant.conf".source = cfg.configurationFile;
|
||||
})
|
||||
|
||||
(mkIf cfg.enable {
|
||||
|
||||
networking.dhcpcd.allowInterfaces = cfg.interfaces;
|
||||
|
||||
networking.usePredictableInterfaceNames = true;
|
||||
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
|
||||
(pkgs.writeShellScriptBin "scan-wifi" ''
|
||||
# todo : use column to make a nice view
|
||||
${pkgs.wirelesstools}/bin/iwlist scan | \
|
||||
grep -v "Interface doesn't support scanning" | \
|
||||
sed -e '/^\s*$/d' | \
|
||||
grep -e "ESSID" -e "Encrypt" | \
|
||||
sed -e "s/Encryption key:on/encrypted/g" | \
|
||||
sed -e "s/Encryption key:off/open/g" | \
|
||||
sed -e "s/ESSID://g" | \
|
||||
xargs -L 2 printf "%9s - '%s'\n"
|
||||
'')
|
||||
|
||||
];
|
||||
})
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
98
nixos/modules/system/x11.nix
Normal file
98
nixos/modules/system/x11.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.system.custom.x11;
|
||||
|
||||
in {
|
||||
|
||||
options.system.custom.x11 = {
|
||||
enable = mkEnableOption "enable x11";
|
||||
autoLoginUser = mkOption {
|
||||
type = with types; str;
|
||||
description = "user to login";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
services.xserver = {
|
||||
|
||||
enable = true;
|
||||
|
||||
# Configure video Drivers
|
||||
# -----------------------
|
||||
videoDrivers = [ "intel" ];
|
||||
deviceSection = ''
|
||||
Option "DRI" "2"
|
||||
Option "TearFree" "true"
|
||||
'';
|
||||
|
||||
# window-manager : Xmonad
|
||||
# -----------------------
|
||||
displayManager = {
|
||||
defaultSession = lib.mkDefault "none+xmonad";
|
||||
autoLogin.enable = lib.mkDefault true;
|
||||
autoLogin.user = cfg.autoLoginUser;
|
||||
lightdm.enable = lib.mkDefault true;
|
||||
};
|
||||
|
||||
desktopManager = {
|
||||
xterm.enable = false;
|
||||
#gnome3.enable = lib.mkDefault true;
|
||||
};
|
||||
windowManager = {
|
||||
xmonad.enable = true;
|
||||
xmonad.enableContribAndExtras = true;
|
||||
i3.enable = true;
|
||||
};
|
||||
|
||||
# mouse/touchpad
|
||||
# --------------
|
||||
libinput = {
|
||||
enable = true;
|
||||
touchpad = {
|
||||
disableWhileTyping = true;
|
||||
tapping = true;
|
||||
scrollMethod = "twofinger";
|
||||
accelSpeed = "2";
|
||||
};
|
||||
};
|
||||
|
||||
# Wacom configuraton
|
||||
# ------------------
|
||||
modules = [ pkgs.xf86_input_wacom ];
|
||||
};
|
||||
|
||||
# Packages
|
||||
# --------
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
dmenu
|
||||
arandr
|
||||
xcalib
|
||||
flameshot
|
||||
xorg.xmodmap
|
||||
feh
|
||||
|
||||
];
|
||||
|
||||
# Xresources config
|
||||
# -----------------
|
||||
# spread the Xresource config
|
||||
# across different files
|
||||
# just add a file into `/etc/X11/Xresource.d/` and it will be
|
||||
# evaluated.
|
||||
services.xserver.displayManager.sessionCommands = ''
|
||||
for file in `ls /etc/X11/Xresource.d/`
|
||||
do
|
||||
${pkgs.xorg.xrdb}/bin/xrdb -merge /etc/X11/Xresource.d/$file
|
||||
done
|
||||
'';
|
||||
environment.etc."/X11/Xresource.d/.keep".text = "";
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue