Browse Source

initial

master
Gürkan Gür 1 year ago
commit
262b75f583
  1. 1
      .gitignore
  2. 5
      config.nix
  3. 38
      home.nix
  4. 34
      modules/file-associations.nix
  5. 349
      modules/files.nix
  6. 14
      modules/includes.nix
  7. 175
      modules/packages.nix
  8. 67
      modules/packages/old-references/autorandr-patched.nix
  9. 17
      modules/packages/old-references/autorandr-rs.nix
  10. 12
      modules/packages/old-references/build_poetry.patch
  11. 53
      modules/packages/old-references/nuitka-latest.nix
  12. 20
      modules/packages/paoutput.nix
  13. 46
      modules/packages/pyvis.nix
  14. 29
      modules/packages/todotxtmenu.nix
  15. 103
      modules/packages/wezterm.nix
  16. 80
      modules/programs.nix
  17. 242
      modules/scripts.nix
  18. 89
      modules/services.nix
  19. 19
      modules/ssh.nix
  20. 8
      modules/variables.nix
  21. 68
      modules/xserver.nix

1
.gitignore vendored

@ -0,0 +1 @@
secrets.nix

5
config.nix

@ -0,0 +1,5 @@
{
# Not used since I am initializing pkgs over home.nix
allowUnfree = true;
allowBroken = true;
}

38
home.nix

@ -0,0 +1,38 @@
{ pkgs, config, ... }:
with import <nixpkgs> {};
with builtins;
with lib;
with import <home-manager/modules/lib/dag.nix> { inherit lib; };
{
imports =
[
./modules/includes.nix
];
home.activation.fuckMicrosoft= dagEntryBefore ["checkLinkTargets"] ''
echo "Removing the crap some moronic apps are placing.."
find ~ -name "*.FUCK" -print -delete
'';
# XXX: declare plugins in zshrc when there is another method than
# "Oh let's write the hashsums of every f-king plugin's every version we use"
home.activation.updateZplug= dagEntryAfter ["writeBoundary"] ''
#!/usr/bin/env zsh
if [ ! -e /tmp/.zplug_updated ] || [ `stat --format=%Y /tmp/.zplug_updated` -le $(( `date +%s` - 86400 )) ]; then
echo "Updating zplug plugins.."
zsh -c "source ~/.zshrc ; zplug update" || echo "Had problems, ignoring!"
touch /tmp/.zplug_updated
else
echo "Skipping zplug update, recently done"
fi
'';
programs.home-manager = {
enable = true;
};
home.stateVersion = "19.03";
}

34
modules/file-associations.nix

@ -0,0 +1,34 @@
{
"application/pdf" = "qpdfview.desktop";
"application/vnd.oasis.opendocument.text" = "writer.desktop";
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" = "writer.desktop";
"application/x-debian-package" = "org.kde.ark.desktop";
"application/x-extension-htm" = "firefox.desktop";
"application/x-extension-html" = "firefox.desktop";
"application/x-extension-shtml" = "firefox.desktop";
"application/x-extension-xht" = "firefox.desktop";
"application/x-extension-xhtml" = "firefox.desktop";
"application/x-xz-compressed-tar" = "org.kde.ark.desktop";
"application/xhtml+xml" = "firefox.desktop";
"application/zip" = "org.kde.ark.desktop";
"image/jpeg" = "lximage-qt.desktop";
"image/png" = "lximage-qt.desktop";
"image/gif" = "lximage-qt.desktop";
"image/x-xcf" = "gimp.desktop";
"inode/directory" = "pcmanfm.desktop";
"application/x-directory" = "pcmanfm.desktop";
"message/rfc822" = "thunderbird.desktop";
"text/html" = "firefox.desktop";
"text/plain" = "geany.desktop";
"video/mp4" = "mpv.desktop";
"video/webm" = "mpv.desktop";
"x-scheme-handler/chrome" = "firefox.desktop";
"x-scheme-handler/ftp" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
"x-scheme-handler/mailto" = "thunderbird.desktop";
"x-scheme-handler/slack" = "slack.desktop";
"x-scheme-handler/msteams" = "teams.desktop";
"x-scheme-handler/vscode" = "code-url-handler.desktop";
"x-scheme-handler/file" = "pcmanfm.desktop";
}

349
modules/files.nix

@ -0,0 +1,349 @@
{ pkgs, ... }:
let
sync = "/home/gurkan/syncfolder";
secrets = import ./secrets.nix;
fileAssociations = import ./file-associations.nix;
in
{
xdg = {
mimeApps = {
enable = true;
defaultApplications = fileAssociations;
};
configFile."mimeapps.list".force = true;
};
home.file = {
# Static stuff
".config/Yubico/u2f_keys".text = secrets.yubicoU2FKeys;
".config/Yubico/YKPersonalization.conf".text = ''
[Customer]
Prefix=0
Used=false
[Export]
Filename=/home/gurkan/export.ycfg
[Flag]
AllowUpdate=true
AppendCr=true
AppendDelay1=false
AppendDelay2=false
AppendTab1=false
AppendTab2=false
FastTrig=false
HmacLt64=true
ManUpdate=false
OathHotp8=false
Pacing10ms=false
Pacing20ms=false
RequireInput=false
SerialBtnVisible=true
StrongPw1=false
StrongPw2=false
StrongPw3=false
TabTirst=false
UseNumericKeypad=false
serialApiVisible=true
serialUsbVisible=false
[Import]
Filename=/home/gurkan/import.ycfg
[Log]
Disabled=true
Filename=/home/gurkan/configuration_log.csv
Format=0
[Preference]
Export=false
'';
".ssh/.folder-README".text = ''
config: Comes from home-manager
keys: Comes from syncthing (with exception of *neversync* regex for keys I don't want to sync)
others: Local files
'';
".zshnix".text = ''
if ! [[ `ssh-add -L | grep nist` ]] && [[ `lsusb | grep "0406 Yubico"` ]]; then
if [[ ! -z `pgrep ssh-add` ]]; then
echo "(There seems to be another instance running)"
fi
ssh-add -s ${pkgs.opensc}/lib/opensc-pkcs11.so
fi
'';
".gist".text = secrets.gistSecret;
".tarsnap.key".text = secrets.tarsnapKey;
".tarsnaprc".text = ''
keyfile ~/.tarsnap.key
print-stats
cachedir ~/.tarsnapcache
'';
".thunderbird/profiles.ini".text = ''
[General]
StartWithLastProfile=1
[Profile0]
Name=default
IsRelative=1
Path=gurkan.default
Default=1
'';
".thunderbird/gurkan.default/user.js".text = ''
user_pref("mailnews.default_news_sort_order", 2);
user_pref("mailnews.default_news_sort_type", 18);
user_pref("mailnews.default_sort_order", 2);
user_pref("beacon.enabled", false);
'';
".thunderbird/gurkan.default/chrome/userChrome.css".text = ''
/* Set default namespace to XUL */
@namespace
url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* Set font size in folder pane */
#folderTree >treechildren::-moz-tree-cell-text {
font-size: 12pt !important;
}
/* Set font size in thread pane */
#threadTree >treechildren::-moz-tree-cell-text {
font-size: 12pt !important;
}
/* Set height for cells in folder pane */
#folderTree >treechildren::-moz-tree-row {
height: 25px !important;
}
/* Set height for cells in thread pane */
#threadTree >treechildren::-moz-tree-row {
height: 25px !important;
}
'';
".mozilla/firefox/installs.ini".text = ''
[72C951DA6087EB20]
Default=gurkan.default
Locked=1
'';
".mozilla/firefox/profiles.ini".text = ''
[Install72C951DA6087EB20]
Default=gurkan.default
Locked=1
[Profile0]
Name=gurkan.default
IsRelative=1
Path=gurkan.default
Default=1
[General]
StartWithLastProfile=1
Version=2
'';
".mozilla/firefox/gurkan.default/user.js".text = ''
user_pref("app.normandy.first_run", false);
user_pref("app.shield.optoutstudies.enabled", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", false);
user_pref("browser.newtabpage.activity-stream.disableSnippets", true);
user_pref("browser.newtabpage.activity-stream.feeds.section.highlights", false);
user_pref("browser.newtabpage.activity-stream.feeds.snippets", false);
user_pref("browser.pocket.enabled", false);
user_pref("browser.tabs.warnOnClose", false);
user_pref("browser.download.useDownloadDir", false);
user_pref("browser.urlbar.clickSelectsAll", true);
user_pref("browser.urlbar.doubleClickSelectsAll", false);
user_pref("dom.webnotifications.enabled", false);
user_pref("extensions.pocket.enabled", false);
user_pref("general.warnOnAboutConfig", false);
user_pref("security.webauth.u2f", true);
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref("browser.tabs.closeWindowWithLastTab", false);
user_pref("browser.cache.disk.smart_size.enabled", false);
user_pref("browser.cache.disk.capacity", 500000);
user_pref("privacy.trackingprotection.fingerprinting.enabled", true);
user_pref("privacy.trackingprotection.cryptomining.enabled", true);
user_pref("browser.toolbars.bookmarks.showOtherBookmarks", false);
user_pref("browser.cache.disk.capacity", 100000);
user_pref("dom.w3c_touch_events.enabled", 1);
'';
".mozilla/firefox/gurkan.default/chrome/userChrome.css".text = ''
#TabsToolbar {
visibility: collapse !important;
}
#sidebar-box[sidebarcommand="treestyletab_piro_sakura_ne_jp-sidebar-action"] #sidebar-header {
display: none;
}
/*
#sidebar-box, #sidebar-box *{ max-width:5em; min-width:50px;}
#sidebar-box:hover, #sidebar-box:hover *{ max-width:none!important;}
*/
:root {
--sidebar-normal-width: 150px;
--sidebar-hover-width: 250px;
--background-color: rgb(0,0,0);
}
#sidebar-box {
position: relative !important;
overflow-x: hidden !important;
min-width: var(--sidebar-normal-width) !important;
max-width: var(--sidebar-normal-width) !important;
-moz-transition: all .2s ease-out .2s !important;
}
#sidebar-box:hover {
margin-left: calc((var(--sidebar-hover-width) - var(--sidebar-normal-width)) * -1) !important;
min-width: var(--sidebar-hover-width) !important;
-moz-transition: all .2s ease-out 2s !important;
}
#sidebar-splitter {
display: none !important;
}
/*
* fullscreen hide
#main-window[inFullscreen] #sidebar-box {
display:none !important;
width: 0px !important;
}
*/
'';
".config/greenclip.cfg".text = ''
Config {
maxHistoryLength = 200,
historyPath = "~/.cache/greenclip.history",
staticHistoryPath = "~/.cache/greenclip.staticHistory",
imageCachePath = "/tmp/",
usePrimarySelectionAsInput = False,
blacklistedApps = [],
trimSpaceFromSelection = True
}'';
".trc".text = secrets.rubyTwitterSecret;
".config/tig/config".text = ''
# Switch to a branch with selected commit
bind generic n !@sh -c "git checkout -b `echo -n %(commit) | head -c 10 | sed 's/^/newbranch_/'` %(commit)"
# copy commit id to clipboard
bind generic c !@sh -c "echo -n %(commit) | xclip -selection c"
# export current diff to a file
bind generic S ?git format-patch -1 -N %(commit)
'';
".config/alacritty/alacritty.yml".text = ''
env:
TERM: xterm-256color
window:
decorations: none
font:
normal:
family: "Fira Code"
bold:
family: "Fira Code"
style: Bold
italic:
family: "Fira Code"
style: Italic
size: 10.0
draw_bold_text_with_bright_colors: true
colors:
primary:
foreground: '0xeaeaea'
background_opacity: 0.95
mouse:
hide_when_typing: true
url:
modifiers: Control
selection:
semantic_escape_chars: ",`|:\"' ()[]{}<>"
window.dynamic_title: true
cursor:
style: Block
unfocused_hollow: true
live_config_reload: true
key_bindings:
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Key4, mods: Control, action: IncreaseFontSize }
- { key: Minus, mods: Control, action: DecreaseFontSize }
'';
".config/picom.conf".text = ''
inactive-opacity = 1.0;
active-opacity = 1;
frame-opacity = 1;
blur-background = true;
blur-background-fixed = true;
blur:
{
method = "gaussian";
size = 10;
deviation = 5.0;
};
no-fading-openclose = true;
use-ewmh-active-win = true;
detect-client-opacity = true;
backend = "glx";
# slock
focus-exclude = [
"! name ~= ''\'' "
];
shadow = true;
shadow-radius = 5;
shadow-offset-x = -5;
shadow-offset-y = -5;
shadow-opacity = 0.5;
shadow-exclude = [
"class_g = 'Firefox' && argb",
"class_g = 'TelegramDesktop' && argb",
"_NET_WM_WINDOW_TYPE:a = '_NET_WM_WINDOW_TYPE_NOTIFICATION'",
"class_g = 'Daily' && argb",
"class_g = 'Mail' && argb"
];
'';
".proxychains/proxychains.conf".text = ''
quiet_mode
[ProxyList]
socks5 127.0.0.1 8080
'';
".config/pylintrc".text = ''
[LOGGING]
disable=logging-format-interpolation
'';
};
}

14
modules/includes.nix

@ -0,0 +1,14 @@
{ config, ... }:
{
imports =
[
./packages.nix
./services.nix
./programs.nix
./variables.nix
./ssh.nix
./files.nix
./xserver.nix
];
}

175
modules/packages.nix

@ -0,0 +1,175 @@
{ config, pkgs, ...}:
let
baseconfig = { allowUnfree = true; };
# In case I want to use the packages I need on other channels
unstable_small = import (
fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable-small.tar.gz
) { config = baseconfig; };
unstable = import (
fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz
) { config = baseconfig; };
bleeding = import (
fetchTarball https://github.com/NixOS/nixpkgs/archive/master.tar.gz
) { config = baseconfig; };
# For overrides
nixpkgs = import <nixpkgs> {};
sysconfig = (import <nixpkgs/nixos> {}).config;
my_scripts = (import ./scripts.nix {pkgs = pkgs;});
in
{
# For overrides
# XXX: move to overlays-compat?
nixpkgs.config = {
enable = true;
allowUnfree = true;
packageOverrides = pkgs: rec {
adminapi = unstable.python38Packages.callPackage ~/.config/nixpkgs/modules/packages/adminapi.nix {};
pyvis = unstable.python38Packages.callPackage ~/.config/nixpkgs/modules/packages/pyvis.nix {};
todotxtmenu = pkgs.callPackage ~/.config/nixpkgs/modules/packages/todotxtmenu.nix {};
wezterm = pkgs.callPackage ~/.config/nixpkgs/modules/packages/wezterm.nix {};
paoutput = pkgs.callPackage ~/.config/nixpkgs/modules/packages/paoutput.nix {};
# @Reference patching apps
# krunner-pass = pkgs.krunner-pass.overrideAttrs (attrs: {
# patches = attrs.patches ++ [ ~/syncfolder/dotfiles/nixos/home/gurkan/.config/nixpkgs/modules/packages/pass-dbus.patch ];
# });
# weechat = (pkgs.weechat.override {
# configure = { availablePlugins, ... }: {
# plugins = with availablePlugins; [
# (python.withPackages (ps: with ps; [
# websocket_client
# dbus-python
# notify
# ]))
# ];
# };
# });
};
# @Reference this is sometimes needed
# allowBroken = true;
};
home.packages = with pkgs;
# Conditionals first
(if sysconfig.networking.hostName == "innixos" || sysconfig.networking.hostName == "innodellix" then [
slack
unstable.teams
gnome3.gnome-keyring # needed for teams
discord
zoom-us
my_scripts.innovpn-toggle
thunderbird
] else [] ) ++ [
# Now overrides
## Java, thank god I am not needing this for a long time
# (
# oraclejdk.override { pluginSupport = true; }
# )
# icedtea_web # java plugin
( pass.withExtensions ( ps: with ps; [ pass-genphrase ]))
( unstable.python38.withPackages ( ps: with ps; [
adminapi
black
coverage
flake8
ipython
libtmux
libvirt
netaddr
pep8
pip
pylint
pynvim
pysnooper
pyvis
pyyaml
requests
setuptools
vimwiki-markdown
virtualenv
xlib
]))
# non-stable stuff, subject to change
unstable.steam
# unstable.update-nix-fetchgit
# Rest is sorted
adbfs-rootless
alacritty
alttab
arandr # I might need manual xrandr one day
arc-kde-theme # for theming kde apps
arc-theme
ark # compressed file manager
blueman # if shits itself, try bluedevil
brightnessctl
calibre # e-book manager written by a jerk
chromium
ffmpeg
ffmpegthumbs
firefox
flameshot
geany
gimp
gimpPlugins.gmic
glxinfo
gnome3.dconf # some apps keep its config in this shit: shotwell
graphviz # some weird tools *sometimes* need this
grobi # no more autorandr
gxkb
imagemagick
inotify-tools
jmtpfs # mount MTP devices easily
# kde-cli-tools # required to open kde-gtk-config
# kde-gtk-config # best GTK theme selector
libnotify
libreoffice
lxqt.lximage-qt
meld # diff tool
mpv
my_scripts.git-cleanmerged
my_scripts.psitool-script
my_scripts.pulseaudio-toggle-hack
my_scripts.tarsnap-dotfiles
my_scripts.xinput-toggle
networkmanagerapplet
numlockx
pamixer # pulseaudio mixer
papirus-icon-theme
paoutput
pavucontrol
pcmanfm-qt # A file-manager which fucking works
# pdftk # split-combine pdfs
picom # X compositor which sucks
playerctl
# poppler_utils # for pdfunite
proxychains
puppet-lint
qpdfview
# qt5ct # QT5 theme selector
slock
spotify
steam-run # helper tool for running shitty binaries
tarsnap
taskwarrior
tdesktop # telegram
todotxtmenu
udiskie
wezterm
xautomation
xclip
xdotool
xlibs.xmodmap
xorg.xdpyinfo
xorg.xev
xorg.xkill
xorg.xwininfo
xournal # annotate pdfs
xsel
];
}

67
modules/packages/old-references/autorandr-patched.nix

@ -0,0 +1,67 @@
{ lib, stdenv
, python3Packages
, fetchFromGitHub
, systemd
, xrandr }:
let
python = python3Packages.python;
version = "1.11";
revision = "5d3b326";
in
stdenv.mkDerivation {
pname = "autorandr";
inherit version;
buildInputs = [ python ];
# no wrapper, as autorandr --batch does os.environ.clear()
buildPhase = ''
substituteInPlace autorandr.py \
--replace 'os.popen("xrandr' 'os.popen("${xrandr}/bin/xrandr' \
--replace '["xrandr"]' '["${xrandr}/bin/xrandr"]'
'';
outputs = [ "out" "man" ];
installPhase = ''
runHook preInstall
make install TARGETS='autorandr' PREFIX=$out
make install TARGETS='bash_completion' DESTDIR=$out/share/bash-completion/completions
make install TARGETS='autostart_config' PREFIX=$out DESTDIR=$out
make install TARGETS='manpage' PREFIX=$man
${if systemd != null then ''
make install TARGETS='systemd udev' PREFIX=$out DESTDIR=$out \
SYSTEMD_UNIT_DIR=/lib/systemd/system \
UDEV_RULES_DIR=/etc/udev/rules.d
substituteInPlace $out/etc/udev/rules.d/40-monitor-hotplug.rules \
--replace /bin/systemctl "/run/current-system/systemd/bin/systemctl"
'' else ''
make install TARGETS='pmutils' DESTDIR=$out \
PM_SLEEPHOOKS_DIR=/lib/pm-utils/sleep.d
make install TARGETS='udev' PREFIX=$out DESTDIR=$out \
UDEV_RULES_DIR=/etc/udev/rules.d
''}
runHook postInstall
'';
src = fetchFromGitHub {
owner = "seqizz";
repo = "autorandr";
rev = revision;
sha256 = "0a2nsvidcj7y343axbfh3nvxyys03ni43cradlj6xkhmqk0yjkd1";
};
meta = with lib; {
homepage = "https://github.com/phillipberndt/autorandr/";
description = "Automatically select a display configuration based on connected devices";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ coroa globin ];
platforms = platforms.unix;
};
}

17
modules/packages/old-references/autorandr-rs.nix

@ -0,0 +1,17 @@
{rustPlatform, fetchFromGitHub, scdoc, installShellFiles}:
rustPlatform.buildRustPackage rec {
name = "autorandr-rs";
src = fetchFromGitHub {
owner = "theotherjimmy";
repo = name;
rev = "c8cd814dcdb25551e9acc7b777979a73b2241612";
sha256 = "1gaw2hjyvbrv7wwf1yr218avxdi6yfm4cshqvnf57mq4c024s7i8";
};
cargoSha256 = "14kascz4ifvmixq7w13vvnzq52q1b6ipw2wkdxarv5phmzmsbmi6";
nativeBuildInputs = [ scdoc installShellFiles ];
preFixup = ''
installManPage $releaseDir/build/${name}-*/out/${name}.1
installManPage $releaseDir/build/${name}-*/out/${name}.5
'';
}

12
modules/packages/old-references/build_poetry.patch

@ -0,0 +1,12 @@
diff --git a/pyproject.toml b/pyproject.toml
index 2c93a39..6c800e2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,3 +24,7 @@ isort = "^4.3"
[tool.black]
line-length = 120
+
+[build-system]
+requires = ["poetry_core>=1.0.0"]
+build-backend = "poetry.core.masonry.api"

53
modules/packages/old-references/nuitka-latest.nix

@ -0,0 +1,53 @@
{ stdenv
, buildPythonPackage
, fetchFromGitHub
, vmprof
, pyqt4
, isPyPy
, pkgs
}:
let
# scons is needed but using it requires Python 2.7
# Therefore we create a separate env for it.
scons = pkgs.python27.withPackages(ps: [ pkgs.scons ]);
in buildPythonPackage rec {
version = "0.6.9.1";
pname = "Nuitka";
src = fetchFromGitHub {
owner = "Nuitka";
repo = "Nuitka";
rev = "262d506035b3738f622fa01d9ce8e597deb417cf";
sha256 = "0lyybhi8gaaafckjvpfchqqanvjx514p492l50gjdskzwi7mv6r0";
};
checkInputs = [ vmprof pyqt4 ];
nativeBuildInputs = [ scons ];
postPatch = ''
patchShebangs tests/run-tests
'' + stdenv.lib.optionalString stdenv.isLinux ''
substituteInPlace nuitka/plugins/standard/ImplicitImports.py --replace 'locateDLL("uuid")' '"${pkgs.utillinux.out}/lib/libuuid.so"'
'';
# We do not want any wrappers here.
postFixup = '''';
checkPhase = ''
tests/run-tests
'';
# Problem with a subprocess (parts)
doCheck = false;
# Requires CPython
disabled = isPyPy;
meta = with stdenv.lib; {
description = "Python compiler with full language support and CPython compatibility";
license = licenses.asl20;
homepage = https://nuitka.net/;
};
}

20
modules/packages/paoutput.nix

@ -0,0 +1,20 @@
{ stdenv, fetchFromGitHub, pulseaudioFull }:
stdenv.mkDerivation {
name = "paoutput";
version = "0.1";
src = fetchFromGitHub {
owner = "davjgardner";
repo = "paoutput";
rev = "223a6af";
sha256 = "1f1cmb9wchxr3g9hdswzlzr11wbqy58cqz56dryp8wpw3brirb02";
};
buildInputs = [ pulseaudioFull ];
installPhase = ''
mkdir -p $out/bin
cp paoutput $out/bin
'';
}

46
modules/packages/pyvis.nix

@ -0,0 +1,46 @@
{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, jinja2
, ipython
, networkx
, jsonpickle
}:
buildPythonPackage rec {
pname = "pyvis";
version = "0.0.1";
format = "pyproject";
disabled = pythonOlder "3.6";
src = fetchFromGitHub {
owner = "WestHealth";
repo = pname;
rev = "4c521302abf9725dcbe7f59962baf85360b2718d";
sha256 = "13qrxls89sgx1f2381wb8lrs3w4vfb4ik09rdy5zhjbdki1cg1hd";
};
# preConfigure = ''
# patchShebangs autogen.sh
# ./autogen.sh
# '';
# patches = [ ./build_poetry.patch ];
# checkInputs = [ pytestCheckHook ];
# Despite living in 'tool.poetry.dependencies',
# these are only used at build time to process the image resource files
nativeBuildInputs = [ jinja2 ipython networkx jsonpickle ];
propagatedBuildInputs = nativeBuildInputs;
meta = with lib; {
description = "Diagram as Code";
homepage = "https://diagrams.mingrammer.com/";
license = licenses.mit;
maintainers = with maintainers; [ addict3d ];
};
}

29
modules/packages/todotxtmenu.nix

@ -0,0 +1,29 @@
{ stdenv
, lib
, fetchurl
}:
stdenv.mkDerivation rec {
name = "todotxtmenu";
version = "1.2.1";
src = fetchurl {
url = "https://github.com/firecat53/${name}/releases/download/v${version}/${name}_${version}_linux_amd64.tar.gz";
sha256 = "0bd807fmiwprn8n1dkkdj76h797x0r1jycy3wxbip7dk2mfypp2s";
};
unpackPhase = ''
tar xvf $src
'';
installPhase = ''
install -m755 -D todotxtmenu $out/bin/todotxtmenu
'';
meta = with lib; {
homepage = https://github.com/firecat53/todotxtmenu/;
description = " Dmenu/Rofi script to manage todo.txt lists";
platforms = platforms.linux;
maintainers = with maintainers; [ seqiz ];
};
}

103
modules/packages/wezterm.nix

@ -0,0 +1,103 @@
{ stdenv
, rustPlatform
, makeRustPlatform
, lib
, fetchFromGitHub
, pkgconfig
, fontconfig
, python3
, openssl
, perl
, dbus
, libX11
, xcbutil
, libxcb
, xcbutilkeysyms
, xcbutilimage
, xcbutilrenderutil
, xcbutilwm # contains xcb-ewmh among others
, libxkbcommon
, libglvnd # libEGL.so.1
, egl-wayland
, wayland
, libGLU
, libGL
, freetype
, zlib
, fenix ? import (builtins.fetchTarball https://github.com/figsoda/fenix/archive/ba0167976a65957ef1d4e569e39e89f77e53f3e3.tar.gz )
, fenixpkgs ? import <nixpkgs> { overlays = [ fenix ]; }
}:
let
runtimeDeps = [
libX11
xcbutil
libxcb
xcbutilkeysyms
xcbutilwm
xcbutilimage
xcbutilrenderutil
libxkbcommon
dbus
libglvnd
zlib
egl-wayland
wayland
libGLU
libGL
fontconfig
freetype
openssl
];
in
# rustPlatform.buildRustPackage {
(makeRustPlatform {
inherit (fenixpkgs.rust-nightly.minimal) cargo rustc;
}).buildRustPackage {
name = "wezterm";
src = fetchFromGitHub {
owner = "wez";
repo = "wezterm";
# rev = "2e7dc70eaf1b13fb19123e5ae606b4e745114c62";
rev = "618f77f2c65d77720613a06b1f0a6be6af12d340";
fetchSubmodules = true;
sha256 = "0qj6dyrswysby2z0g8ag0mvsgl8gf68sl5iymzif8mknl05q9phg";
};
cargoSha256 = "16s46qc83kkg8bp0c446iabk1bcdjwda2i3shnirp8pq2a0b3569";
nativeBuildInputs = [
pkgconfig
python3
perl
fenixpkgs.rust-nightly.default.toolchain
];
buildInputs = runtimeDeps;
postPatch = ''
echo "2021-g1" > .tag
'';
preFixup = lib.optionalString stdenv.isLinux ''
for artifact in wezterm wezterm-gui wezterm-mux-server strip-ansi-escapes; do
patchelf --set-rpath "${lib.makeLibraryPath runtimeDeps}" $out/bin/$artifact
done
'' + lib.optionalString stdenv.isDarwin ''
mkdir -p "$out/Applications"
OUT_APP="$out/Applications/WezTerm.app"
cp -r assets/macos/WezTerm.app "$OUT_APP"
rm $OUT_APP/*.dylib
cp -r assets/shell-integration/* "$OUT_APP"
ln -s $out/bin/{wezterm,wezterm-mux-server,wezterm-gui,strip-ansi-escapes} "$OUT_APP"
'';
# prevent further changes to the RPATH
dontPatchELF = true;
meta = with lib; {
description = "A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust";
homepage = "https://wezfurlong.org/wezterm";
license = licenses.mit;
maintainers = with maintainers; [ seqizz ];
platforms = platforms.unix;
};
}

80
modules/programs.nix

@ -0,0 +1,80 @@
{config, pkgs, ...}:
let
# baseconfig = { allowUnfree = true; };
# In case I want to use the packages I need on other channels
# unstable = import (
# fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz
# ) { config = baseconfig; };
secrets = import ./secrets.nix;
in
{
programs = {
git = {
enable = true;
userEmail = secrets.gitUserEmail;
userName = secrets.gitUserName;
aliases = {
# foksheet: Send the last change amended to last commit quickly, except on master branch
fs = ''
!CURBRANCH=$(git symbolic-ref --short HEAD) && if [ "''${CURBRANCH}" = "master" ]; then echo "Cant do this on master, master" && exit 1; fi && git add -A && git commit -a --amend --no-edit && git push origin +''${CURBRANCH}
'';
# Checkout the master branch, update it and remove the source branch if it is already merged on upstream
reclean = ''
!CURBRANCH=$(git symbolic-ref --short HEAD) && if [ "''${CURBRANCH}" = "master" ]; then echo "Cant do this on master, master" && exit 1; fi && git checkout master && git pull && git branch -d ''${CURBRANCH}
'';
# I am just lazy
new = "checkout -b";
# checkout latest upstream (good for getting force-pushes)
getlast = "!sh -c 'git fetch --all && git reset --hard origin/$(git symbolic-ref --short HEAD)'";
# checkout to branch of given merge request (for gitlab)
# usage: git mr <source> <MR number> (git mr origin 1010)
mr = "!sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -";
# checkout to branch of given pull request (for github)
# usage: git pr <source> <PR number> (git pr origin 1010)
pr = "!sh -c 'git fetch $1 pull/$2/head:$2 && git checkout $2' -";
};
delta = {
enable = true;
options = {
dark = "true";
};
};
extraConfig = {
pull = {
ff = "only";
};
};
};
browserpass = {
enable = true;
browsers = [ "firefox" ];
};
rofi = {
enable = true;
pass = {
enable = true;
extraConfig = ''
USERNAME_field='login'
'';
};
width = 40;
lines = 20;
font = "Fira Code 14";
theme = "glue_pro_blue";
extraConfig = {
matching = "regex";
max-history-size = 200;
kb-clear-line = "Control+a";
kb-move-front = "" ;
kb-cancel = "Control+c,Escape,Control+g,Control+bracketleft";
};
};
};
}

242
modules/scripts.nix

@ -0,0 +1,242 @@
{pkgs, ... }:
{
pulseaudio-toggle-hack = pkgs.writeScriptBin "pulseaudio-toggle-hack" ''
for input in $(pactl list sources | grep ^Source | sed 's/.*#//'); do
pactl set-source-mute $input toggle
done
'';
psitool-script = pkgs.writeScriptBin "psitool-script" ''
#!/usr/bin/env python3
from hashlib import sha256
from pickle import load, dump
from socket import gethostname
from time import time
def current_psi_dict():
with open('/proc/pressure/cpu', 'r') as psifile:
total = psifile.read().split(' ')[4].split('=')[1]
return {
'value': int(total),
'time': int(time())
}
def write_current_value(temp_file):
current_value = current_psi_dict()
with open(temp_file, 'wb') as valuefile:
dump(current_value, valuefile)
def get_last_value(name):
result = False
with open(name, 'rb') as valuefile:
result = load(valuefile)
return result
def get_filename():
hash = sha256(gethostname().encode('utf-8')).hexdigest()[:8]
return '/tmp/{}_psi'.format(hash)
def get_difference(temp_file):
last_value = get_last_value(temp_file)
if last_value is False:
return "-1"
current_value = current_psi_dict()
time_difference = current_value['time'] - last_value['time']
value_difference = current_value['value'] - last_value['value']
if time_difference == 0:
# Prevent division by zero, feed last one
return current_value['value']
return(int(value_difference / time_difference))
def main():
temp_file = get_filename()
try:
with open(temp_file) as f:
print(get_difference(temp_file))
except IOError:
print('-1')
finally:
write_current_value(temp_file)
main()
'';
git-cleanmerged = pkgs.writeScriptBin "git-cleanmerged" ''
#!/usr/bin/env bash
git fetch --all && for branch in $(git branch -l | grep -v master); do git branch -d $branch ; done
'';
innovpn-toggle = pkgs.writeScriptBin "innovpn-toggle" ''
#!/usr/bin/env bash
if [[ $(nmcli con show --active | grep tun0) ]]; then
echo Active, deactivating
nmcli con down VPN-aw
else
echo Not active, activating
nmcli con up VPN-aw
fi
'';
tarsnap-dotfiles = pkgs.writeScriptBin "tarsnap-dotfiles" ''
#!/usr/bin/env bash
tarsnap -c --keyfile $HOME/.tarsnap.key --cachedir $HOME/.tarsnapcache -f dotfiles-`date +%Y-%m-%d_%H-%M-%S` $HOME/syncfolder/dotfiles
'';
auto-rotate = pkgs.writeScriptBin "auto-rotate" ''
#!/usr/bin/env bash
# Auto rotate screen based on device orientation
# Needs iio (monitor-sensor) and inotifytools
LOG=/tmp/rotation_sensor.log
export DISPLAY=:0
# put your display name here
DNAME=eDP-1
# may change grep to match your touchscreen
INDEV=$(${pkgs.xorg.xinput}/bin/xinput --list | ${pkgs.gnugrep}/bin/grep Finger | ${pkgs.gnused}/bin/sed 's/.*id=\([0-9]*\).*/\1/')
function rotate {
#echo ---- rotete ----
ORIENTATION=$1
CUR_ROT=$(${pkgs.xorg.xrandr}/bin/xrandr -q --verbose | ${pkgs.gnugrep}/bin/grep $DNAME | ${pkgs.coreutils}/bin/coreutils --coreutils-prog=cut -d" " -f6)
NEW_ROT="normal"
CTM="1 0 0 0 1 0 0 0 1"
# Set the actions to be taken for each possible orientation
case "$ORIENTATION" in
normal)
NEW_ROT="normal"
CTM="1 0 0 0 1 0 0 0 1"
# gsettings set com.canonical.Unity.Launcher launcher-position Top
;;
bottom-up)
NEW_ROT="inverted"
CTM="-1 0 1 0 -1 1 0 0 1"
# gsettings set com.canonical.Unity.Launcher launcher-position Top
;;
right-up)
CTM="0 1 0 -1 0 1 0 0 1"
NEW_ROT="right"
# gsettings set com.canonical.Unity.Launcher launcher-position Left
;;
left-up)
NEW_ROT="left"
CTM="0 -1 1 1 0 0 0 0 1"
# gsettings set com.canonical.Unity.Launcher launcher-position Left
;;
esac
# echo ORIENTATION: $ORIENTATION
# echo INDEV: $INDEV
# echo DNAME: $DNAME
# echo DISPLAY: $DISPLAY
# echo NEW_ROT: $NEW_ROT
# echo CUR_ROT: $CUR_ROT
# echo CTM: $CTM
if [ "$NEW_ROT" != "$CUR_ROT" ] ; then
${pkgs.xorg.xrandr}/bin/xrandr --output $DNAME --rotate $NEW_ROT
${pkgs.xorg.xinput}/bin/xinput set-prop $INDEV 'Coordinate Transformation Matrix' $CTM
fi
}
# set default orientation
# rotate left-up
# kill old monitor-sensor if any
killall monitor-sensor >> /dev/null 2>&1
# Clear sensor.log at the beginning
> $LOG
# Launch monitor-sensor and store the output in a variable that can be parsed by the rest of the script
${pkgs.iio-sensor-proxy}/bin/monitor-sensor >> $LOG 2>&1 &
# Parse output or monitor sensor to get the new orientation whenever the log file is updated
# Possibles are: normal, bottom-up, right-up, left-up
# Light data will be ignored
while ${pkgs.inotify-tools}/bin/inotifywait -e modify $LOG; do
# Read the last line that was added to the file and get the orientation
ORIENTATION=$(${pkgs.gnugrep}/bin/grep 'orientation changed' $LOG | ${pkgs.coreutils}/bin/coreutils --coreutils-prog=tail -n 1 | ${pkgs.gawk}/bin/awk '{print $NF}')
if [[ $ORIENTATION != "" ]] ; then
rotate $ORIENTATION
# then wipe the log again
> $LOG
fi
done
'';
xinput-toggle = pkgs.writeScriptBin "xinput-toggle" ''
#!/usr/bin/env ${pkgs.bash}/bin/bash
if [[ $1 == "query" ]]; then
device=$2
state=$(xinput list-props "$device" | grep "Device Enabled" | grep -o "[01]$")
if [ $state == '1' ];then
echo "on"
else