From 72b9f757edf5ffd7e4bc62578c7c99bd7f026544 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Sat, 21 Nov 2020 23:54:07 +0300 Subject: [PATCH] stuff --- .gitattributes | 1 + README.md | 116 +--- flake.lock | 404 ------------- hosts/default.nix | 44 ++ hosts/lungmen.nix | 169 ++++++ hosts/niximg.nix | 12 + lib/utils.nix | 24 + local/locale.nix | 6 + overlays/hikari.nix | 3 + profiles/core.nix | 100 ++++ profiles/develop/default.nix | 7 + profiles/develop/editor/default.nix | 6 + profiles/develop/editor/kakoune.nix | 10 + profiles/develop/godot.nix | 7 + profiles/network/default.nix | 10 + profiles/network/dns/default.nix | 1 + profiles/network/dns/nextdns.nix | 6 + profiles/network/dns/stubby/default.nix | 6 + profiles/network/dns/stubby/nextdns.nix | 16 + profiles/network/iwd.nix | 7 + profiles/network/networkmanager.nix | 5 + profiles/network/ssh.nix | 8 + profiles/network/wpa_supplicant.nix | 8 + users/patriot/default.nix | 32 ++ users/patriot/home.nix | 732 ++++++++++++++++++++++++ users/profiles/hikari.nix | 207 +++++++ users/root/default.nix | 4 +- 27 files changed, 1430 insertions(+), 521 deletions(-) create mode 100644 .gitattributes delete mode 100644 flake.lock create mode 100644 hosts/default.nix create mode 100644 hosts/lungmen.nix create mode 100644 hosts/niximg.nix create mode 100644 lib/utils.nix create mode 100644 local/locale.nix create mode 100644 overlays/hikari.nix create mode 100644 profiles/core.nix create mode 100644 profiles/develop/default.nix create mode 100644 profiles/develop/editor/default.nix create mode 100644 profiles/develop/editor/kakoune.nix create mode 100644 profiles/develop/godot.nix create mode 100644 profiles/network/default.nix create mode 100644 profiles/network/dns/default.nix create mode 100644 profiles/network/dns/nextdns.nix create mode 100644 profiles/network/dns/stubby/default.nix create mode 100644 profiles/network/dns/stubby/nextdns.nix create mode 100644 profiles/network/iwd.nix create mode 100644 profiles/network/networkmanager.nix create mode 100644 profiles/network/ssh.nix create mode 100644 profiles/network/wpa_supplicant.nix create mode 100644 users/patriot/default.nix create mode 100644 users/patriot/home.nix create mode 100644 users/profiles/hikari.nix diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5c975fa --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +secrets/* filter=git-crypt diff=git-crypt diff --git a/README.md b/README.md index f347f4a..9177b09 100644 --- a/README.md +++ b/README.md @@ -1,115 +1 @@ -[![Bors enabled](https://bors.tech/images/badge_small.svg)](https://app.bors.tech/repositories/32678) -[![MIT License](https://img.shields.io/github/license/divnix/devos)][mit] -[![NixOS](https://img.shields.io/badge/NixOS-unstable-blue.svg?style=flat&logo=NixOS&logoColor=white)](https://nixos.org) - -> #### ⚠ Advisory ⚠ -> DevOS requires the [flakes][flakes] feature available via an _experimental_ -> branch of [nix][nix]. Until nix 3.0 is released, this project -> should be considered unstable, though quite usable as flakes have been -> maturing _well_ [for a while](https://github.com/divnix/devos/tree/17713c22d07c54525c728c62060a0428b76dee3b). - -# Introduction -DevOS grants a simple template to use, deploy and manage [NixOS][nixos] systems -for personal and productive use. A sane repository structure is provided, -integrating several popular projects like [home-manager][home-manager], -[devshell][devshell], and [more](./doc/integrations). - -Striving for ___nix first™___ solutions with unobstrusive implementations, -a [flake centric][flake-doc] approach is taken for useful conveniences such as -[automatic source updates](./pkgs#automatic-source-updates). - -Skip the indeterminate nature of other systems, _and_ the perceived -tedium of bootstrapping Nix. It's easier than you think! - -### Status: Beta -Although this project has already matured quite a bit, especially through -recent outfactoring of [`digga`][digga], a fair amount of api polishing is still -expected. There are unstable versions (0._x_._x_) to help users keep track -of changes and progress. - -## Getting Started -Check out the [guide](https://devos.divnix.com/start) to get up and running. -Also, have a look at [_flake.nix_][toc]. If anything is not immediately -discoverable from there through [`digga`][digga] library's [`mkFlake`][mk-flake], -please file a bug report. - -## In the Wild -The author maintains his own branch, so you can take inspiration, direction, or -make critical comments about the [code][please]. 😜 - -## Motivation -NixOS provides an amazing abstraction to manage our environment, but that new -power can sometimes bring feelings of overwhelm and confusion. Having a turing -complete system can easily lead to unlimited complexity if we do it wrong. -Instead, we should have a community consensus on how to manage a NixOS system -and its satellite projects, from which best practices can evolve. - -___The future is declarative! 🎉___ - -## Community Profiles -There are two branches from which to choose: [core][core] and -[community][community]. The community branch builds on core and includes -several ready-made profiles for discretionary use. - -Every package and NixOS profile declared in community is uploaded to -[cachix](./integrations/cachix.md), so everything provided is available -without building anything. This is especially useful for the packages that are -[overridden](./concepts/overrides.md) from master, as without the cache, -rebuilds are quite frequent. - -## Shoulders -This work does not reinvent the wheel. It stands on the [shoulders of the -following giants][giants]: - -### :onion: — like the layers of an onion -- [`divnix/digga`][digga] -- [`gytis-ivaskevicius/flake-utils-plus`][fup] -- [`numtide/flake-utils`][fu] - -### :family: — like family -- [`numtide/devshell`][devshell] -- [`serokell/deploy-rs`][deploy] -- [`NixOS/nixpkgs`][nixpkgs] - -:heart: - -## Inspiration & Art -- [hlissner/dotfiles][dotfiles] -- [nix-user-chroot](https://github.com/nix-community/nix-user-chroot) -- [Nickel](https://github.com/tweag/nickel) -- [Awesome Nix](https://github.com/nix-community/awesome-nix) -- [devshell](https://github.com/numtide/devshell) - -## Divnix -The divnix org is an open space that spontaniously formed out of "the Nix". -It is really just a place where otherwise unrelated people a) get -together and b) stuff done. - -It's a place to stop "geeking out in isolation" (or within company boundaries), -experiment and learn together and iterate quickly on best practices. That's what it is. - -It might eventually become a non-profit if that's not too complicated or if those -goals are sufficiently upstreamed into "the Nix", dissolved. - -# License -DevOS is licensed under the [MIT License][mit]. - -[mk-flake]: https://github.com/divnix/digga/tree/master/src/mkFlake -[nixpkgs]: https://github.com/NixOS/nixpkgs -[deploy]: https://github.com/serokell/deploy-rs -[toc]: https://github.com/divnix/devos/blob/core/flake.nix -[giants]: https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants -[digga]: https://github.com/divnix/digga -[fup]: https://github.com/gytis-ivaskevicius/flake-utils-plus -[fu]: https://github.com/numtide/flake-utils -[devshell]: https://github.com/numtide/devshell -[nix]: https://nixos.org/manual/nix/stable -[mit]: https://mit-license.org -[nixos]: https://nixos.org/manual/nixos/stable -[home-manager]: https://nix-community.github.io/home-manager -[flakes]: https://nixos.wiki/wiki/Flakes -[flake-doc]: https://github.com/NixOS/nix/blob/master/src/nix/flake.md -[core]: https://github.com/divnix/devos -[community]: https://github.com/divnix/devos/tree/community -[dotfiles]: https://github.com/hlissner/dotfiles -[please]: https://github.com/nrdxp/devos/tree/nrd +Based on , with my own configs. Changes directory structure a bit. diff --git a/flake.lock b/flake.lock deleted file mode 100644 index b082071..0000000 --- a/flake.lock +++ /dev/null @@ -1,404 +0,0 @@ -{ - "nodes": { - "ci-agent": { - "inputs": { - "flake-compat": "flake-compat", - "nix-darwin": [ - "darwin" - ], - "nixos-20_09": [ - "nixos" - ], - "nixos-unstable": [ - "latest" - ], - "pre-commit-hooks-nix": "pre-commit-hooks-nix" - }, - "locked": { - "lastModified": 1619088868, - "narHash": "sha256-l9db+HpNIkY41MonGE8z4pbkjBa5BdzJTG5AxV7V7Lw=", - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "rev": "08f953a263518a3af0ca28cd887020ff3465bdf5", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-agent", - "type": "github" - } - }, - "darwin": { - "inputs": { - "nixpkgs": [ - "latest" - ] - }, - "locked": { - "lastModified": 1613595894, - "narHash": "sha256-MOk/7rCAUB5Lf4GL+HimvyAAZXYEw8gWsq5nW4PPQQA=", - "owner": "LnL7", - "repo": "nix-darwin", - "rev": "5c3146b75d5d478f0693d0ea6c83f1da8382ff56", - "type": "github" - }, - "original": { - "owner": "LnL7", - "repo": "nix-darwin", - "type": "github" - } - }, - "deploy": { - "inputs": { - "flake-compat": "flake-compat_2", - "naersk": "naersk", - "nixpkgs": "nixpkgs", - "utils": "utils" - }, - "locked": { - "lastModified": 1616406726, - "narHash": "sha256-n9zmgxR03QNrvs9/fHewqE0j3SjL7Y+cglBCFu3U3rg=", - "owner": "serokell", - "repo": "deploy-rs", - "rev": "9e405fbc5ab5bacbd271fd78c6b6b6877c4d9f8d", - "type": "github" - }, - "original": { - "owner": "serokell", - "repo": "deploy-rs", - "type": "github" - } - }, - "devshell": { - "locked": { - "lastModified": 1618523768, - "narHash": "sha256-Gev9da35pHUey3kGz/zrJFc/9ICs++vPCho7qB1mqd8=", - "owner": "numtide", - "repo": "devshell", - "rev": "709fe4d04a9101c9d224ad83f73416dce71baf21", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, - "digga": { - "inputs": { - "deploy": "deploy", - "devshell": "devshell", - "nixlib": "nixlib", - "nixpkgs": "nixpkgs_2", - "utils": "utils_2" - }, - "locked": { - "lastModified": 1621354376, - "narHash": "sha256-b597Jj8B1Nq4NX/Gl/+bYGKqJxpSfUtr1Nmp9m1DND8=", - "owner": "divnix", - "repo": "digga", - "rev": "5ef9b8cabbc10c9b4fe5534107224c7241c63b3d", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "digga", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1606424373, - "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1606424373, - "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-utils": { - "locked": { - "lastModified": 1620759905, - "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "home": { - "inputs": { - "nixpkgs": [ - "nixos" - ] - }, - "locked": { - "lastModified": 1616724076, - "narHash": "sha256-SwbPXLjN2sLy4NL/GhodiJrdkIVZwGGTGiCN3JxH1cU=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "fedfd430f96695997b3eaf8d7e82ca79406afa23", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "latest": { - "locked": { - "lastModified": 1619400530, - "narHash": "sha256-7ZO7B+b9i1wFbHw62EFT+iwuBBpXeA/fcHlR63Z4J0w=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e8dc8adab655eb27957859c62bef11484b53f639", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "naersk": { - "inputs": { - "nixpkgs": [ - "latest" - ] - }, - "locked": { - "lastModified": 1610392286, - "narHash": "sha256-3wFl5y+4YZO4SgRYK8WE7JIS3p0sxbgrGaQ6RMw+d98=", - "owner": "nmattia", - "repo": "naersk", - "rev": "d7bfbad3304fd768c0f93a4c3b50976275e6d4be", - "type": "github" - }, - "original": { - "owner": "nmattia", - "ref": "master", - "repo": "naersk", - "type": "github" - } - }, - "naersk_2": { - "inputs": { - "nixpkgs": [ - "latest" - ] - }, - "locked": { - "lastModified": 1614785451, - "narHash": "sha256-TPw8kQvr2UNCuvndtY+EjyXp6Q5GEW2l9UafXXh1XmI=", - "owner": "nmattia", - "repo": "naersk", - "rev": "e0fe990b478a66178a58c69cf53daec0478ca6f9", - "type": "github" - }, - "original": { - "owner": "nmattia", - "repo": "naersk", - "type": "github" - } - }, - "nixlib": { - "locked": { - "lastModified": 1620519687, - "narHash": "sha256-+6Dd72b2CASuXm2W7KRxZIE7AOy/dj4mU28vaF+zxcs=", - "owner": "divnix", - "repo": "nixpkgs.lib", - "rev": "c7b6169809c5f74dd0c34f3d69e9d12ba4d448de", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "nixos": { - "locked": { - "lastModified": 1615797423, - "narHash": "sha256-5NGDZXPQzuoxf/42NiyC9YwwhwzfMfIRrz3aT0XHzSc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "266dc8c3d052f549826ba246d06787a219533b8f", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-unstable", - "type": "indirect" - } - }, - "nixos-hardware": { - "locked": { - "lastModified": 1615652054, - "narHash": "sha256-jqXKU8Ovpi7MmPRqGf2FB3QOPcZtGwO2MFc0AYiOPjg=", - "owner": "nixos", - "repo": "nixos-hardware", - "rev": "31f61b90ddb9257b94888ee17ccf96236e180c76", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixos-hardware", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1610942247, - "narHash": "sha256-PKo1ATAlC6BmfYSRmX0TVmNoFbrec+A5OKcabGEu2yU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "7d71001b796340b219d1bfa8552c81995017544a", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1620962350, - "narHash": "sha256-9ASW4d4/Z8HmRvuJI8rxbEOTbXTBpQ8y+CmFYBwtXzE=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5d4a430472cafada97888cc80672fab255231f57", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "type": "github" - } - }, - "nur": { - "locked": { - "lastModified": 1615921934, - "narHash": "sha256-nURGM869KKA1+c1SHHsXKYcPXhHIuxWBjNXjJ90OzRQ=", - "owner": "nix-community", - "repo": "NUR", - "rev": "faf862e8cf009edfa38ecc61188f7a6ace293552", - "type": "github" - }, - "original": { - "id": "nur", - "type": "indirect" - } - }, - "pkgs": { - "inputs": { - "nixpkgs": [ - "nixos" - ] - }, - "locked": { - "narHash": "sha256-Zs7dc0dNNa0Z3//+Gckxj7SKrMqVovY0xZZ1z8xWnEg=", - "path": "./pkgs", - "type": "path" - }, - "original": { - "path": "./pkgs", - "type": "path" - } - }, - "pre-commit-hooks-nix": { - "flake": false, - "locked": { - "lastModified": 1617783930, - "narHash": "sha256-SigoU2LWM1fMggqfM9H8XEIvjOjBVQ/wj/zrn02J28c=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "2d169bb1b23f3b71a894a66ea81f45c788943248", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, - "root": { - "inputs": { - "ci-agent": "ci-agent", - "darwin": "darwin", - "digga": "digga", - "home": "home", - "latest": "latest", - "naersk": "naersk_2", - "nixos": "nixos", - "nixos-hardware": "nixos-hardware", - "nur": "nur", - "pkgs": "pkgs" - } - }, - "utils": { - "locked": { - "lastModified": 1610051610, - "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "utils_2": { - "inputs": { - "flake-utils": "flake-utils" - }, - "locked": { - "lastModified": 1620801141, - "narHash": "sha256-XPJ+/nP/s218E11R+4LJyvkrQXvdT3D6TzNjfWVYZnI=", - "owner": "gytis-ivaskevicius", - "repo": "flake-utils-plus", - "rev": "1a742047f3f7c97b22768ba7738ac5a01052099e", - "type": "github" - }, - "original": { - "owner": "gytis-ivaskevicius", - "ref": "staging", - "repo": "flake-utils-plus", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..5fa953e --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,44 @@ +inputs@{ home, impermanence, mynex, nixpkgs, self, pkgs, system, ... }: +let + utils = import ../lib/utils.nix { inherit lib pkgs; }; + + inherit (nixpkgs) lib; + inherit (utils) recImport; + + config = hostName: + lib.nixosSystem { + inherit system; + + specialArgs = { + usr = { inherit utils; }; + util = utils; + nixosPersistence = "${impermanence}/nixos.nix"; + }; + + modules = let + inherit (home.nixosModules) home-manager; + inherit (mynex.nixosModules) security networking; + + core = ../profiles/core.nix; + + global = { + networking.hostName = hostName; + nix.nixPath = [ + "nixpkgs=${nixpkgs}" + "nixos-config=/etc/nixos/configuration.nix" + "nixpkgs-overlays=/etc/nixos/overlays" + ]; + + nixpkgs = { inherit pkgs; }; + nixpkgs.overlays = [ mynex.overlay ]; + }; + + local = import "${toString ./.}/${hostName}.nix"; + in [ core global local home-manager security networking ]; + }; + + hosts = recImport { + dir = ./.; + _import = config; + }; +in hosts diff --git a/hosts/lungmen.nix b/hosts/lungmen.nix new file mode 100644 index 0000000..2ca3451 --- /dev/null +++ b/hosts/lungmen.nix @@ -0,0 +1,169 @@ +{ config, lib, pkgs, modulesPath, nixosPersistence, ... }: +let + btrfsPartPath = "/dev/disk/by-uuid/9a2ac687-7937-4ffa-9b59-8b5c13026466"; + btrfsOptions = [ "compress-force=zstd" "noatime" ]; + + btrfsDiff = pkgs.writeScriptBin "btrfs-diff" '' + #!${pkgs.bash}/bin/bash + set -euo pipefail + + sudo mkdir -p /mnt + sudo mount -o subvol=/ ${btrfsPartPath} /mnt + + OLD_TRANSID=$(sudo btrfs subvolume find-new /mnt/root-blank 9999999) + + sudo btrfs subvolume find-new "/mnt/root" "$OLD_TRANSID" | + sed '$d' | + cut -f17- -d' ' | + sort | + uniq | + while read path; do + path="/$path" + if [ -L "$path" ]; then + : # The path is a symbolic link, so is probably handled by NixOS already + elif [ -d "$path" ]; then + : # The path is a directory, ignore + else + echo "$path" + fi + done + + sudo umount /mnt + ''; +in { + imports = [ + ../users/patriot + ../users/root + ../profiles/network + ../profiles/develop + (modulesPath + "/installer/scan/not-detected.nix") + nixosPersistence + ]; + + boot = { + loader = { + efi.canTouchEfiVariables = true; + systemd-boot.enable = true; + }; + kernelPackages = pkgs.linuxPackages_latest; + supportedFilesystems = [ "btrfs" ]; + initrd = { + availableKernelModules = + [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + kernelModules = [ "amdgpu" ]; + }; + kernelModules = [ "kvm-amd" ]; + extraModulePackages = [ ]; + initrd.postDeviceCommands = pkgs.lib.mkBefore '' + mkdir -p /mnt + mount -o subvol=/ ${btrfsPartPath} /mnt + btrfs subvolume list -o /mnt/root | + cut -f9 -d' ' | + while read subvolume; do + echo "deleting /$subvolume subvolume..." + btrfs subvolume delete "/mnt/$subvolume" + done && + echo "deleting /root subvolume..." && + btrfs subvolume delete /mnt/root + echo "restoring blank /root subvolume" + btrfs subvolume snapshot /mnt/root-blank /mnt/root + umount /mnt + ''; + }; + + fileSystems."/" = { + device = btrfsPartPath; + fsType = "btrfs"; + options = [ "subvol=root" ] ++ btrfsOptions; + }; + + fileSystems."/home" = { + device = btrfsPartPath; + fsType = "btrfs"; + options = [ "subvol=home" ] ++ btrfsOptions; + }; + + fileSystems."/nix" = { + device = btrfsPartPath; + fsType = "btrfs"; + options = [ "subvol=nix" ] ++ btrfsOptions; + }; + + fileSystems."/persist" = { + device = btrfsPartPath; + fsType = "btrfs"; + options = [ "subvol=persist" ] ++ btrfsOptions; + neededForBoot = true; + }; + + fileSystems."/var/log" = { + device = btrfsPartPath; + fsType = "btrfs"; + options = [ "subvol=log" ] ++ btrfsOptions; + neededForBoot = true; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/5784-BBB1"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + zramSwap = { + enable = true; + algorithm = "zstd"; + }; + + nix.maxJobs = lib.mkDefault 4; + + security = { + mitigations.disable = true; + allowSimultaneousMultithreading = false; + # Deleting root subvolume makes sudo show lecture every boot + sudo.extraConfig = '' + Defaults lecture = never + ''; + }; + + sound.enable = true; + hardware = { + opengl = { + driSupport = true; + driSupport32Bit = true; + enable = true; + extraPackages = with pkgs; [ + amdvlk + libvdpau-va-gl + vaapiVdpau + libva + vulkan-loader + ]; + extraPackages32 = with pkgs.pkgsi686Linux; + [ libvdpau-va-gl vaapiVdpau libva vulkan-loader ] + ++ [ pkgs.driversi686Linux.amdvlk ]; + }; + pulseaudio = { + enable = true; + support32Bit = true; + }; + }; + # virtualisation.docker.enable = true; + + environment = { + systemPackages = [ btrfsDiff ]; + persistence."/persist" = { + directories = [ "/etc/nixos" "/var/lib/docker/" ]; + files = [ "/etc/machine-id" ]; + }; + }; + networking.interfaces.enp6s0.useDHCP = true; + + services.xserver = { + enable = true; + # displayManager.gdm.enable = true; + # desktopManager.gnome3.enable = true; + videoDrivers = [ "amdgpu" ]; + }; + + system.stateVersion = "20.09"; +} diff --git a/hosts/niximg.nix b/hosts/niximg.nix new file mode 100644 index 0000000..3b3cb51 --- /dev/null +++ b/hosts/niximg.nix @@ -0,0 +1,12 @@ +{ modulesPath, ... }: { + imports = [ + # passwd is nixos by default + ../users/nixos + ../users/root + "${modulesPath}/installer/cd-dvd/iso-image.nix" + ]; + + isoImage.makeEfiBootable = true; + isoImage.makeUsbBootable = true; + networking.networkmanager.enable = true; +} diff --git a/lib/utils.nix b/lib/utils.nix new file mode 100644 index 0000000..a0f25e5 --- /dev/null +++ b/lib/utils.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, ... }: +let + inherit (builtins) attrNames isAttrs isInt readDir toJSON; + + inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix; +in rec { + # mapFilterAttrs :: + # (name -> value -> bool ) + # (name -> value -> { name = any; value = any; }) + # attrs + mapFilterAttrs = seive: f: attrs: filterAttrs seive (mapAttrs' f attrs); + + recImport = { dir, _import ? base: import "${dir}/${base}.nix" }: + mapFilterAttrs (_: v: v != null) (n: v: + if n != "default.nix" && hasSuffix ".nix" n && v == "regular" + + then + let name = removeSuffix ".nix" n; in nameValuePair (name) (_import name) + + else + nameValuePair ("") (null)) (readDir dir); + + pkgBin = name: "${pkgs."${name}"}/bin/${name}"; +} diff --git a/local/locale.nix b/local/locale.nix new file mode 100644 index 0000000..2c59d90 --- /dev/null +++ b/local/locale.nix @@ -0,0 +1,6 @@ +{ ... }: { + console.keyMap = "trq"; + i18n.defaultLocale = "tr_TR.UTF-8"; + time.timeZone = "Turkey"; + services.xserver.layout = "tr"; +} diff --git a/overlays/hikari.nix b/overlays/hikari.nix new file mode 100644 index 0000000..32fc2d6 --- /dev/null +++ b/overlays/hikari.nix @@ -0,0 +1,3 @@ +final: prev: { + hikari = prev.hikari.overrideAttrs (old: rec { version = "2.2.2"; }); +} diff --git a/profiles/core.nix b/profiles/core.nix new file mode 100644 index 0000000..4d72210 --- /dev/null +++ b/profiles/core.nix @@ -0,0 +1,100 @@ +{ config, lib, pkgs, util, ... }: +let + inherit (util) pkgBin; + inherit (lib) fileContents mkIf; + +in { + imports = [ ../local/locale.nix ]; + + boot = { + tmpOnTmpfs = true; + loader.systemd-boot.configurationLimit = 10; + }; + + console.font = "7x14"; + + environment = let + coreBin = v: "${pkgs.coreutils}/bin/${v}"; + nixBin = "${config.nix.package}/bin/nix"; + in { + systemPackages = with pkgs; [ + bat + exa + ripgrep + curl + git + gotop + gptfdisk + iputils + lm_sensors + mkpasswd + ]; + + shellAliases = let ifSudo = string: mkIf config.security.sudo.enable string; + in { + g = pkgBin "git"; + + grep = "${pkgs.ripgrep}/bin/rg"; + cat = "${pkgBin "bat"} -pp --theme=base16"; + c = "${pkgBin "bat"} -pp --theme=base16"; + + df = "${coreBin "df"} -h"; + free = "${pkgs.procps}/bin/free -h"; + + ls = pkgBin "exa"; + l = "${pkgBin "exa"} -lhg --git"; + la = "${pkgBin "exa"} -lhg --git -a"; + t = "${pkgBin "exa"} -lhg --git -T"; + ta = "${pkgBin "exa"} -lhg --git -a -T"; + + n = nixBin; + nf = "${nixBin} flake"; + nfc = "${nixBin} flake check"; + nfu = "${nixBin} flake update"; + nfua = "${nixBin} flake update --recreate-lock-file"; + nfs = "${nixBin} flake show"; + np = "${nixBin} profile"; + npl = "${nixBin} profile info"; + npi = "${nixBin} profile install"; + npr = "${nixBin} profile remove"; + nsh = "${nixBin} shell"; + ndev = "${nixBin} develop"; + + nosce = "cd /etc/nixos"; + nosr = ifSudo "sudo nixos-rebuild --fast"; + nosrs = ifSudo "sudo nixos-rebuild switch"; + nosrb = ifSudo "sudo nixos-rebuild boot"; + nosrt = ifSudo "sudo nixos-rebuild test"; + ncg = ifSudo "sudo nix-collect-garbage"; + ncgdo = ifSudo "sudo nix-collect-garbage --delete-old"; + + top = pkgBin "gotop"; + + myip = + "${pkgs.dnsutils}/bin/dig +short myip.opendns.com @208.67.222.222 2>&1"; + }; + }; + + nix = { + package = pkgs.nixFlakes; + autoOptimiseStore = true; + optimise.automatic = true; + allowedUsers = [ "@wheel" ]; + trustedUsers = [ "root" "@wheel" ]; + extraOptions = '' + experimental-features = nix-command flakes ca-references + ''; + }; + + # security = { + # hideProcessInformation = true; + # protectKernelImage = true; + # }; + + programs.command-not-found.enable = false; + + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + users.mutableUsers = false; +} diff --git a/profiles/develop/default.nix b/profiles/develop/default.nix new file mode 100644 index 0000000..437e24a --- /dev/null +++ b/profiles/develop/default.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: { + imports = [ ./editor ]; + + environment.systemPackages = with pkgs; [ git gcc tokei gnumake ]; + + documentation.dev.enable = true; +} diff --git a/profiles/develop/editor/default.nix b/profiles/develop/editor/default.nix new file mode 100644 index 0000000..464fa42 --- /dev/null +++ b/profiles/develop/editor/default.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: { + imports = [ ./kakoune.nix ]; + + environment.systemPackages = with pkgs; [ nixfmt ]; + environment.shellAliases = { nixf-all = "nixfmt **/**.nix"; }; +} diff --git a/profiles/develop/editor/kakoune.nix b/profiles/develop/editor/kakoune.nix new file mode 100644 index 0000000..b2e41db --- /dev/null +++ b/profiles/develop/editor/kakoune.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: { + environment.systemPackages = with pkgs; [ kakoune ]; + + environment.sessionVariables = { + EDITOR = "${pkgs.kakoune}/bin/kak"; + VISUAL = "${pkgs.kakoune}/bin/kak"; + }; + + environment.shellAliases = { k = "${pkgs.kakoune}/bin/kak"; }; +} diff --git a/profiles/develop/godot.nix b/profiles/develop/godot.nix new file mode 100644 index 0000000..f331544 --- /dev/null +++ b/profiles/develop/godot.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: { + environment.systemPackages = with pkgs; [ + godot-bin + godot-headless-bin + godot-server-bin + ]; +} diff --git a/profiles/network/default.nix b/profiles/network/default.nix new file mode 100644 index 0000000..2420b8d --- /dev/null +++ b/profiles/network/default.nix @@ -0,0 +1,10 @@ +{ + imports = [ ./dns ]; + + networking.useDHCP = false; + + networking.dhcpcd.extraConfig = '' + noarp + nodelay + ''; +} diff --git a/profiles/network/dns/default.nix b/profiles/network/dns/default.nix new file mode 100644 index 0000000..15fc2df --- /dev/null +++ b/profiles/network/dns/default.nix @@ -0,0 +1 @@ +{ imports = [ ./nextdns.nix ]; } diff --git a/profiles/network/dns/nextdns.nix b/profiles/network/dns/nextdns.nix new file mode 100644 index 0000000..bf4ef01 --- /dev/null +++ b/profiles/network/dns/nextdns.nix @@ -0,0 +1,6 @@ +{ ... }: { + services.nextdns = { + enable = true; + arguments = [ "-config" "75e43d" ]; + }; +} diff --git a/profiles/network/dns/stubby/default.nix b/profiles/network/dns/stubby/default.nix new file mode 100644 index 0000000..7851537 --- /dev/null +++ b/profiles/network/dns/stubby/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ ./nextdns.nix ]; + + networking.networkmanager.dns = "none"; + services.stubby.enable = true; +} diff --git a/profiles/network/dns/stubby/nextdns.nix b/profiles/network/dns/stubby/nextdns.nix new file mode 100644 index 0000000..9b34004 --- /dev/null +++ b/profiles/network/dns/stubby/nextdns.nix @@ -0,0 +1,16 @@ +{ + services.stubby = { + roundRobinUpstreams = false; + upstreamServers = let nextDnsId = "75e43d"; + in '' + - address_data: 45.90.28.0 + tls_auth_name: "${nextDnsId}.dns1.nextdns.io" + - address_data: 2a07:a8c0::0 + tls_auth_name: "${nextDnsId}.dns1.nextdns.io" + - address_data: 45.90.30.0 + tls_auth_name: "${nextDnsId}.dns2.nextdns.io" + - address_data: 2a07:a8c1::0 + tls_auth_name: "${nextDnsId}.dns2.nextdns.io" + ''; + }; +} diff --git a/profiles/network/iwd.nix b/profiles/network/iwd.nix new file mode 100644 index 0000000..04506f9 --- /dev/null +++ b/profiles/network/iwd.nix @@ -0,0 +1,7 @@ +{ + imports = [ ./dns ]; + + networking.wireless.iwd.enable = true; + networking.networkmanager.wifi.backend = "iwd"; + services.connman.wifi.backend = "iwd"; +} diff --git a/profiles/network/networkmanager.nix b/profiles/network/networkmanager.nix new file mode 100644 index 0000000..217c6c3 --- /dev/null +++ b/profiles/network/networkmanager.nix @@ -0,0 +1,5 @@ +{ + imports = [ ./dns ]; + + networking.networkmanager.enable = true; +} diff --git a/profiles/network/ssh.nix b/profiles/network/ssh.nix new file mode 100644 index 0000000..a0bddaa --- /dev/null +++ b/profiles/network/ssh.nix @@ -0,0 +1,8 @@ +{ + services.openssh = { + enable = true; + challengeResponseAuthentication = false; + passwordAuthentication = false; + forwardX11 = true; + }; +} diff --git a/profiles/network/wpa_supplicant.nix b/profiles/network/wpa_supplicant.nix new file mode 100644 index 0000000..1ce15b1 --- /dev/null +++ b/profiles/network/wpa_supplicant.nix @@ -0,0 +1,8 @@ +{ + imports = [ ./dns ]; + + networking.wireless = { + enable = true; + userControlled.enable = true; + }; +} diff --git a/users/patriot/default.nix b/users/patriot/default.nix new file mode 100644 index 0000000..ddaec94 --- /dev/null +++ b/users/patriot/default.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: { + imports = [ ./home.nix ]; + + users.users.patriot = { + isNormalUser = true; + createHome = true; + home = "/home/patriot"; + extraGroups = [ "wheel" "adbusers" "dialout" "docker" ]; + shell = pkgs.zsh; + hashedPassword = + "$6$spzqhAyJfhHy$iHgLBlhjGn1l8PnbjJdWTn1GPvcjMqYNKUzdCe/7IrX6sHNgETSr/Nfpdmq9FCXLhrAfwHOd/q/8SvfeIeNX4/"; + }; + + xdg.portal = { + enable = true; + gtkUsePortal = true; + extraPortals = with pkgs; [ + xdg-desktop-portal + xdg-desktop-portal-gtk + xdg-desktop-portal-wlr + ]; + }; + + programs = { + adb.enable = true; + steam.enable = true; + java = { + enable = true; + package = pkgs.jre8; + }; + }; +} diff --git a/users/patriot/home.nix b/users/patriot/home.nix new file mode 100644 index 0000000..ab81c87 --- /dev/null +++ b/users/patriot/home.nix @@ -0,0 +1,732 @@ +{ config, lib, pkgs, util, ... }: +let + inherit (lib) mapAttrs' nameValuePair; + inherit (builtins) readDir; + inherit (util) pkgBin; + + nixosConfig = config; + + name = "Yusuf Bera Ertan"; + email = "y.bera003.06@protonmail.com"; + + font = "Iosevka"; + fontSize = 10; + fontComb = "${font} ${toString fontSize}"; + fontPackage = pkgs.iosevka; + + wallpaper = pkgs.fetchurl { + url = "https://static.zerochan.net/Mayer.%28Arknights%29.full.2724381.jpg"; + hash = "sha256-W/nr3Ukm1pNoMWfebYiQ3v3i9OSH98PVV3tqTwRVbSU="; + name = "wallpaper"; + }; + + kideSrc = pkgs.fetchgit { + url = "https://gitlab.com/yusdacra/kide.git"; + rev = "c4116d433add520d8e18382e0bfee9c49bf67fd0"; + sha256 = "sha256-RTYl0rFR7Tv5UisQXL4Wucrlw3NZeTKIqrXTdx095y0="; + fetchSubmodules = true; + }; + kideFiles = + mapAttrs' (n: _: nameValuePair "kak/${n}" { source = "${kideSrc}/${n}"; }) + (readDir kideSrc); + kideDeps = with pkgs; [ + fzf + bat + ripgrep + universal-ctags + kak-lsp + wl-clipboard + xclip + ]; + + colorSchemeLight = { + primary = { + normal = { + background = "fbf3db"; + foreground = "53676d"; + }; + bright = { + background = "d5cdb6"; + foreground = "3a4d53"; + }; + }; + normal = { + black = "ece3cc"; + red = "d2212d"; + green = "489100"; + yellow = "ad8900"; + blue = "0072d4"; + magenta = "ca4898"; + cyan = "009c8f"; + white = "909995"; + }; + bright = { + black = "d5cdb6"; + red = "cc1729"; + green = "428b00"; + yellow = "a78300"; + blue = "006dce"; + magenta = "c44392"; + cyan = "00978a"; + white = "3a4d53"; + }; + }; + + colorSchemeDark = { + primary = { + normal = { + background = "181818"; + foreground = "b9b9b9"; + }; + bright = { + background = "3b3b3b"; + foreground = "dedede"; + }; + }; + normal = { + black = "252525"; + red = "ed4a46"; + green = "70b433"; + yellow = "dbb32d"; + blue = "368aeb"; + magenta = "eb6eb7"; + cyan = "3fc5b7"; + white = "777777"; + }; + bright = { + black = "3b3b3b"; + red = "ff5e56"; + green = "83c746"; + yellow = "efc541"; + blue = "4f9cfe"; + magenta = "ff81ca"; + cyan = "56d8c9"; + white = "dedede"; + }; + }; + + colorScheme = + if builtins.pathExists ./light then colorSchemeLight else colorSchemeDark; + + bgColor = colorScheme.primary.normal.background; + fgColor = colorScheme.primary.bright.foreground; + acColor = colorScheme.normal.red; + acColor2 = colorScheme.normal.yellow; + + alacrittyColors = { + primary = { + background = "0x${bgColor}"; + foreground = "0x${fgColor}"; + }; + normal = lib.mapAttrs (_: v: "0x${v}") colorScheme.normal; + bright = lib.mapAttrs (_: v: "0x${v}") colorScheme.bright; + }; + + # sway attrs reused + focusedWorkspace = { + background = "#${bgColor}"; + border = "#${acColor}"; + text = "#${acColor}"; + }; + activeWorkspace = { + background = "#${bgColor}"; + border = "#${colorScheme.primary.bright.background}"; + text = "#${fgColor}"; + }; + inactiveWorkspace = { + background = "#${bgColor}"; + border = "#${bgColor}"; + text = "#${fgColor}"; + }; + urgentWorkspace = { + background = "#${bgColor}"; + border = "#${acColor2}"; + text = "#${acColor2}"; + }; + addIndSway = x: { + background = x.background; + border = x.border; + childBorder = x.border; + text = x.text; + indicator = "#111111"; # don't care + }; + fonts = [ fontComb ]; +in { + home-manager.users.patriot = { config, pkgs, ... }: { + imports = [ ../profiles/hikari.nix ]; + + fonts.fontconfig.enable = true; + home = { + homeDirectory = nixosConfig.users.users.patriot.home; + packages = + with pkgs; + [ + discord + fontPackage + bitwarden + pfetch + neofetch + gnupg + imv + mpv + youtube-dl + ffmpeg + mupdf + steam-run + lutris + xdg_utils + # xdg-user-dirs + # gnome3.zenity + # x11 docker stuff + # x11docker + # weston + # xwayland + # xpra + # xdotool + # xorg.setxkbmap + # xorg.xkbcomp + # xorg.xauth + ] ++ kideDeps; + file = { + "wallpaper.png".source = ${wallpaper}; + }; + }; + + wayland.windowManager = { + hikari = { + enable = true; + inherit font; + }; + sway = { + enable = false; + extraSessionCommands = '' + export SDL_VIDEODRIVER=wayland + # needs qt5.qtwayland in systemPackages + export QT_QPA_PLATFORM=wayland + export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" + # Fix for some Java AWT applications (e.g. Android Studio), + # use this if they aren't displayed properly: + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; + config = { + inherit fonts; + bars = [ ]; # no + colors = { + background = "#${bgColor}"; + focused = addIndSway focusedWorkspace; + focusedInactive = addIndSway inactiveWorkspace; + unfocused = addIndSway activeWorkspace; + urgent = addIndSway urgentWorkspace; + }; + gaps.smartBorders = "on"; + menu = "${pkgBin "rofi"} -show drun | ${pkgs.sway}/bin/swaymsg --"; + modifier = "Mod4"; + terminal = pkgBin "alacritty"; + keybindings = let + mod = config.wayland.windowManager.sway.config.modifier; + cat = pkgs.coreutils + "/bin/cat"; + grim = pkgBin "grim"; + slurp = pkgBin "slurp"; + pactl = pkgs.pulseaudio + "/bin/pactl"; + playerctl = pkgBin "playerctl"; + wf-recorder = pkgBin "wf-recorder"; + wl-copy = pkgs.wl-clipboard + "/bin/wl-copy"; + wl-paste = pkgs.wl-clipboard + "/bin/wl-paste"; + shotFile = homeDir + "/shots/shot_$(date '+%Y_%m_%d_%H_%M')"; + in lib.mkOptionDefault { + "${mod}+q" = "kill"; + # Screenshot and copy it to clipboard + "Mod1+s" = '' + exec export SFILE="${shotFile}.png" && ${grim} "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png + ''; + # Save selected area as a picture and copy it to clipboard + "Mod1+Shift+s" = '' + exec export SFILE="${shotFile}.png" && ${grim} -g "$(${slurp})" "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png + ''; + # Record screen + "Mod1+r" = ''exec ${wf-recorder} -f "${shotFile}.mp4"''; + # Record an area + "Mod1+Shift+r" = + ''exec ${wf-recorder} -g "$(${slurp})" -f "${shotFile}.mp4"''; + # Stop recording + "Mod1+c" = "exec pkill -INT wf-recorder"; + "XF86AudioRaiseVolume" = "exec ${pactl} set-sink-volume 0 +5%"; + "XF86AudioLowerVolume" = "exec ${pactl} set-sink-volume 0 -5%"; + "XF86AudioMute" = "exec ${pactl} set-sink-mute 0 toggle"; + "XF86AudioPlay" = "exec ${playerctl} play-pause"; + "XF86AudioPrev" = "exec ${playerctl} previous"; + "XF86AudioNext" = "exec ${playerctl} next"; + "XF86AudioStop" = "exec ${playerctl} stop"; + }; + input = { + "*" = { + xkb_layout = nixosConfig.services.xserver.layout; + accel_profile = "flat"; + }; + }; + output = { "*" = { bg = wallpaper + " fill"; }; }; + }; + }; + }; + + programs = { + alacritty = { + enable = true; + settings = { + font = { + normal = { family = font; }; + size = fontSize; + }; + colors = alacrittyColors; + }; + }; + tmux = { + enable = true; + newSession = true; + secureSocket = true; + baseIndex = 1; + escapeTime = 0; + keyMode = "vi"; + terminal = "tmux-256color"; + shortcut = "a"; + extraConfig = '' + set -ga terminal-overrides ',*256col*:Tc' + set -g status off + ''; + }; + qutebrowser = { + enable = true; + settings = { + content.javascript.enabled = false; + colors.webpage.darkmode.enabled = true; + tabs = { + tabs_are_windows = true; + show = "never"; + }; + statusbar.show = "in-mode"; + }; + extraConfig = let + domains = [ + "github.com" + "gitlab.com" + "nixos.org" + "protonmail.com" + "bitwarden.com" + "duckduckgo.com" + "youtube.com" + "docker.com" + ]; + enableJsForDomain = d: '' + config.set('content.javascript.enabled', True, 'https://*.${d}') + ''; + in lib.concatStrings (map enableJsForDomain domains); + }; + git = { + enable = true; + aliases = { + a = "add"; + b = "branch"; + c = "commit"; + d = "diff"; + l = "log"; + s = "status"; + co = "checkout"; + dc = "diff --cached"; + qc = "commit -am"; + pl = "pull"; + ps = "push"; + rb = "rebase"; + rs = "restore"; + rv = "revert"; + ss = "stash"; + rst = "reset"; + rss = "restore --staged"; + ssp = "stash pop"; + ssl = "stash list"; + ssd = "stash drop"; + }; + extraConfig = { pull.rebase = true; }; + lfs.enable = true; + signing = { + key = "E1C119F91F4CAE53E8445CAFBB57FCE7E35984F6"; + signByDefault = true; + }; + userName = name; + userEmail = email; + }; + ssh = { + enable = true; + compression = true; + hashKnownHosts = true; + userKnownHostsFile = "~/.local/share/ssh/known-hosts"; + extraConfig = '' + Host hub.darcs.net + ControlMaster no + ForwardAgent no + ForwardX11 no + Ciphers +aes256-cbc + MACs +hmac-sha1 + ''; + }; + zsh = { + enable = true; + autocd = true; + enableVteIntegration = true; + enableAutosuggestions = true; + enableCompletion = true; + plugins = let + fast-syntax-highlighting = { + name = "fast-syntax-highlighting"; + src = "${pkgs.zsh-fast-syntax-highlighting}"; + }; + per-directory-history = { + name = "per-directory-history"; + src = pkgs.fetchFromGitHub { + owner = "jimhester"; + repo = "per-directory-history"; + rev = "d2e291dd6434e340d9be0e15e1f5b94f32771c06"; + hash = "sha256-VHRgrVCqzILqOes8VXGjSgLek38BFs9eijmp0JHtD5Q="; + }; + }; + in [ fast-syntax-highlighting per-directory-history ]; + # xdg compliant + dotDir = ".config/zsh"; + history.path = ".local/share/zsh/history"; + loginExtra = '' + if [ "$(${pkgs.coreutils}/bin/tty)" = "/dev/tty1" ]; then + exec ${pkgBin "hikari"} + fi + ''; + shellAliases = nixosConfig.environment.shellAliases // { + rember = '' + ${pkgs.kakoune-unwrapped}/bin/kak -e "try %(gtd-jump-today)" "${homeDir}/rember/stuff$(date '+_%m_%Y').gtd" + ''; + }; + }; + starship = { + enable = true; + settings = { + add_newline = false; + character.symbol = ">"; + directory = { + truncation_length = 2; + truncate_to_repo = false; + }; + }; + }; + direnv = { + enable = true; + enableNixDirenvIntegration = true; + }; + fzf.enable = true; + rofi = let + bgc = "#${bgColor}"; + fgc = "#${fgColor}"; + acc = "#${acColor}"; + in { + enable = true; + colors = { + window = { + background = bgc; + border = bgc; + separator = bgc; + }; + rows = { + normal = { + background = bgc; + foreground = fgc; + backgroundAlt = bgc; + highlight = { + background = bgc; + foreground = acc; + }; + }; + }; + }; + font = fontComb; + separator = "none"; + terminal = pkgBin "alacritty"; + }; + waybar = { + enable = true; + settings = [ + { + layer = "top"; + position = "top"; + modules-left = [ ]; + modules-center = [ ]; + modules-right = [ "pulseaudio" "cpu" "memory" "temperature" "clock" "tray" ]; + modules = { + "tray" = { + spacing = 8; + }; + "cpu" = { + format = "/cpu {usage}/"; + }; + "memory" = { + format = "/mem {}/"; + }; + "temperature" = { + hwmon-path = "/sys/class/hwmon/hwmon2/temp2_input"; + format = "/tmp {temperatureC}C/"; + }; + "pulseaudio" = { + format = "/vol {volume}/ {format_source}"; + format-bluetooth = "/volb {volume}/ {format_source}"; + format-bluetooth-muted = "/volb/ {format_source}"; + format-muted = "/vol/ {format_source}"; + format-source = "/mic {volume}/"; + format-source-muted = "/mic/"; + }; + }; + } + ]; + style = '' + * { + border: none; + border-radius: 0; + /* `otf-font-awesome` is required to be installed for icons */ + font-family: ${font}; + font-size: ${toString fontSize}px; + min-height: 0; + } + + window#waybar { + background-color: #222222; + border-bottom: 0px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + transition-property: background-color; + transition-duration: .5s; + } + + #workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; + border-bottom: 3px solid transparent; + } + + /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ + #workspaces button:hover { + background: rgba(0, 0, 0, 0.2); + box-shadow: inherit; + border-bottom: 3px solid #ffffff; + } + + #workspaces button.focused { + background-color: #64727D; + border-bottom: 3px solid #ffffff; + } + + #workspaces button.urgent { + background-color: #eb4d4b; + } + + #mode { + background-color: #64727D; + border-bottom: 3px solid #ffffff; + } + + #clock, + #battery, + #cpu, + #memory, + #temperature, + #backlight, + #network, + #pulseaudio, + #custom-media, + #tray, + #mode, + #idle_inhibitor, + #mpd { + padding: 0 10px; + margin: 0 4px; + color: #ffffff; + } + + #clock { + background-color: #64727D; + color: #000000; + } + + label:focus { + background-color: #000000; + } + + #cpu { + background-color: #2ecc71; + color: #000000; + } + + #memory { + background-color: #9b59b6; + color: #000000; + } + + #pulseaudio { + background-color: #f1c40f; + color: #000000; + } + + #pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; + } + + #temperature { + background-color: #f0932b; + color: #000000; + } + + #temperature.critical { + background-color: #eb4d4b; + color: #000000; + } + + #tray { + background-color: #2980b9; + } + ''; + }; + }; + + services = { + gpg-agent = { + enable = true; + enableSshSupport = true; + sshKeys = [ "8369D9CA26C3EAAAB8302A88CEE6FD14B58AA965" ]; + defaultCacheTtl = 3600 * 6; + defaultCacheTtlSsh = 3600 * 6; + maxCacheTtl = 3600 * 24; + maxCacheTtlSsh = 3600 * 24; + grabKeyboardAndMouse = false; + pinentryFlavor = "gtk2"; + }; + }; + + xdg = { + enable = true; + configFile = { + "kak/user/kakrc".text = '' + source "%val{config}/user/color/colorscheme.kak" + ''; + "kak/user/color/colorscheme.kak".text = '' + evaluate-commands %sh{ + fg="rgb:${colorScheme.primary.normal.foreground}" + bg="rgb:${colorScheme.primary.normal.background}" + br_fg="rgb:${colorScheme.primary.bright.foreground}" + br_bg="rgb:${colorScheme.primary.bright.background}" + + red="rgb:${colorScheme.normal.red}" + green="rgb:${colorScheme.normal.green}" + yellow="rgb:${colorScheme.normal.yellow}" + blue="rgb:${colorScheme.normal.blue}" + magenta="rgb:${colorScheme.normal.magenta}" + cyan="rgb:${colorScheme.normal.cyan}" + + br_red="rgb:${colorScheme.bright.red}" + br_green="rgb:${colorScheme.bright.green}" + br_yellow="rgb:${colorScheme.bright.yellow}" + br_blue="rgb:${colorScheme.bright.blue}" + br_magenta="rgb:${colorScheme.bright.magenta}" + br_cyan="rgb:${colorScheme.bright.cyan}" + + echo " + set-face global value $yellow+b + set-face global type $br_yellow + set-face global variable $magenta + set-face global module $blue + set-face global function $br_cyan + set-face global string $br_green + set-face global keyword $br_red+b + set-face global operator $br_cyan + set-face global attribute $yellow + set-face global comment $fg + set-face global meta $br_yellow + set-face global builtin $br_fg+b + + set-face global title $blue+u + set-face global header $br_cyan+u + set-face global bold $br_fg+b + set-face global italic $br_fg+i + set-face global mono $br_green + set-face global block $yellow + set-face global link $blue + set-face global bullet $br_magenta + set-face global list $magenta + + set-face global Default $br_fg,$bg + set-face global PrimarySelection $bg,$br_fg + set-face global SecondarySelection $br_fg,$br_bg+i + set-face global PrimaryCursor $bg,$red+b + set-face global SecondaryCursor $bg,$br_cyan+i + set-face global MatchingChar $bg,$blue + set-face global Search $br_fg,$green + set-face global CurrentWord $br_fg,$blue + + set-face global MenuForeground $cyan,$br_bg+b + set-face global MenuBackground $br_fg,$bg + + set-face global Information $br_yellow,$bg + set-face global Error $br_bg,$br_red + + set-face global BufferPadding $bg,$bg + set-face global Whitespace $bg + set-face global StatusLine $br_fg,$bg + set-face global StatusLineInfo $yellow,$bg + + set-face global LineNumbers default + set-face global LineNumberCursor default,default+r + " + } + ''; + "kak-lsp/kak-lsp.toml".text = '' + snippet_support = true + verbosity = 2 + + [semantic_scopes] + variable = "variable" + entity_name_function = "function" + entity_name_type = "type" + variable_other_enummember = "variable" + entity_name_namespace = "module" + + [semantic_tokens] + type = "type" + variable = "variable" + namespace = "module" + function = "function" + string = "string" + keyword = "keyword" + operator = "operator" + comment = "comment" + + [semantic_modifiers] + documentation = "documentation" + readonly = "default+d" + + [server] + timeout = 1800 + + [language.rust] + filetypes = ["rust"] + roots = ["Cargo.toml"] + command = "${pkgBin "rust-analyzer"}" + + [language.nix] + filetypes = ["nix"] + roots = ["flake.nix", "shell.nix", ".git"] + command = "${pkgBin "rnix-lsp"}" + ''; + "nix/nix.conf".text = nixosConfig.nix.extraOptions; + "nixpkgs/config.nix".text = '' + { + android_sdk.accept_license = true; + allowUnfree = true; + } + ''; + } // kideFiles; + }; + }; +} diff --git a/users/profiles/hikari.nix b/users/profiles/hikari.nix new file mode 100644 index 0000000..4edf3d7 --- /dev/null +++ b/users/profiles/hikari.nix @@ -0,0 +1,207 @@ +{ lib, config, pkgs, ... }: +with lib; +let + cfg = config.wayland.windowManager.hikari; +in { + options.wayland.windowManager.hikari = { + enable = mkEnableOption "hikari window manager"; + font = mkOption { + type = types.str; + default = "Iosevka"; + }; + }; + + config = mkIf cfg.enable { + home.packages = with pkgs; [ hikari ]; + + xdg = { + enable = true; + configFile = { + "hikari/hikari.conf".text = '' + ui { + border = 1 + gap = 0 + step = 120 + font = "${cfg.font} 10" + + colorscheme { + background = 0x282C34 + foreground = 0x000000 + selected = 0xF5E094 + grouped = 0xFDAF53 + first = 0xB8E673 + conflict = 0xED6B32 + insert = 0xE3C3FA + active = 0xFFFFFF + inactive = 0x465457 + } + } + + outputs { + "*" { + background = "${config.home.homeDirectory}/wallpaper.png" + } + } + + inputs { + keyboards { + "*" { + xkb = { + layout = "tr" + } + } + } + } + + layouts { + # main stack + s = { + scale = { + min = 0.5 + max = 0.75 + } + left = single + right = stack + } + + # main queue + q = { + scale = 0.75 + top = single + bottom = queue + } + + f = full + h = stack + v = queue + g = grid + } + + actions { + terminal = "${pkgs.alacritty}/bin/alacritty" + run = "${pkgs.wofi}/bin/wofi --show drun" + } + + bindings { + keyboard { + "L+0" = workspace-switch-to-sheet-0 + "L+1" = workspace-switch-to-sheet-1 + "L+2" = workspace-switch-to-sheet-2 + "L+3" = workspace-switch-to-sheet-3 + "L+4" = workspace-switch-to-sheet-4 + "L+5" = workspace-switch-to-sheet-5 + "L+6" = workspace-switch-to-sheet-6 + "L+7" = workspace-switch-to-sheet-7 + "L+8" = workspace-switch-to-sheet-8 + "L+9" = workspace-switch-to-sheet-9 + "L+numbersign" = workspace-switch-to-sheet-alternate + "L+Period" = workspace-switch-to-sheet-current + "L+j" = workspace-switch-to-sheet-next + "L+k" = workspace-switch-to-sheet-prev + "L+Comma" = workspace-switch-to-sheet-next-inhabited + "LS+Comma" = workspace-switch-to-sheet-prev-inhabited + "LSC+g" = workspace-show-group + "LSC+i" = workspace-show-invisible + "LSC+Period" = workspace-show-all + "LC+n" = workspace-cycle-next + "LC+p" = workspace-cycle-prev + + "LC+i" = sheet-show-invisible + "LC+Period" = sheet-show-all + "LC+g" = sheet-show-group + + "LA+r" = layout-reset + "LA+Return" = layout-restack-append + "LAS+Return" = layout-restack-prepend + "L+Home" = layout-cycle-view-first + "L+End" = layout-cycle-view-last + "L+n" = layout-cycle-view-next + "L+p" = layout-cycle-view-prev + "L+x" = layout-exchange-view-next + "LS+x" = layout-exchange-view-prev + "LA+x" = layout-exchange-view-main + + "LS+0" = view-pin-to-sheet-0 + "LS+1" = view-pin-to-sheet-1 + "LS+2" = view-pin-to-sheet-2 + "LS+3" = view-pin-to-sheet-3 + "LS+4" = view-pin-to-sheet-4 + "LS+5" = view-pin-to-sheet-5 + "LS+6" = view-pin-to-sheet-6 + "LS+7" = view-pin-to-sheet-7 + "LS+8" = view-pin-to-sheet-8 + "LS+9" = view-pin-to-sheet-9 + "LS+numbersign" = view-pin-to-sheet-alternate + "LS+Period" = view-pin-to-sheet-current + "LS+j" = view-pin-to-sheet-next + "LS+k" = view-pin-to-sheet-prev + + "L+q" = view-quit + "L+Tab" = view-cycle-next + "LS+Tab" = view-cycle-prev + + "L+Up" = view-move-up + "L+Down" = view-move-down + "L+Left" = view-move-left + "L+Right" = view-move-right + "LA+Up" = view-decrease-size-up + "LAS+Up" = view-increase-size-up + "LA+Down" = view-increase-size-down + "LAS+Down" = view-decrease-size-down + "LA+Left" = view-decrease-size-left + "LAS+Left" = view-increase-size-left + "LA+Right" = view-increase-size-right + "LAS+Right" = view-decrease-size-right + "LS+Up" = view-snap-up + "LS+Down" = view-snap-down + "LS+Left" = view-snap-left + "LS+Right" = view-snap-right + "L+r" = view-reset-geometry + + "L+minus" = view-toggle-maximize-vertical + "L+less" = view-toggle-maximize-horizontal + "L+f" = view-toggle-maximize-full + "L5+plus" = view-toggle-floating + "L+i" = view-toggle-invisible + "L5+p" = view-toggle-public + + "L+l" = mode-enter-layout + "L+s" = mode-enter-sheet-assign + "L+g" = mode-enter-group-assign + "L+m" = mode-enter-mark-assign + "L+acute" = mode-enter-mark-select + "LS+acute" = mode-enter-mark-switch-select + "LCA+g" = mode-enter-input-grab + + "LS+Backspace" = lock + "LCA+q" = quit + "LCA+r" = reload + + "L+Return" = action-terminal + "L+d" = action-run + + "A+F1" = vt-switch-to-1 + "A+F2" = vt-switch-to-2 + "A+F3" = vt-switch-to-3 + "A+F4" = vt-switch-to-4 + "A+F5" = vt-switch-to-5 + "A+F6" = vt-switch-to-6 + "A+F7" = vt-switch-to-7 + "A+F8" = vt-switch-to-8 + "A+F9" = vt-switch-to-9 + } + + mouse { + "L+left" = mode-enter-move + "L+right" = mode-enter-resize + } + } + ''; + "hikari/autostart".source = pkgs.writeScriptBin "hikari-autostart" '' + #!${pkgs.stdenv.shell} + ${pkgs.waybar} & + ''; + }; + }; + }; +} diff --git a/users/root/default.nix b/users/root/default.nix index f38c739..5bf59e1 100644 --- a/users/root/default.nix +++ b/users/root/default.nix @@ -1,5 +1,5 @@ { ... }: -# recommend using `hashedPassword` { - users.users.root.password = ""; + users.users.root.initialHashedPassword = + "$6$XLWo1sPpgp63Zm$XHBbULH9q1gb/.yalPPU/I7EgTcW80bM.moCjIe/qGyOwE47VcXNVbTHloBZdIWQq0MfIG0IxInAu59.oJyos/"; }