From 82abea22377d54be47d1166876844d9c83cc4133 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 2 Oct 2021 00:08:00 +1000 Subject: [PATCH] initial devOS --- CHANGELOG.md | 114 +++++ COPYING | 18 + README.md | 91 ++++ bors.toml | 5 + bowl/backup.nix | 34 -- bowl/box.nix | 29 -- bowl/common.nix | 115 ----- bowl/dns.nix | 11 - bowl/headphones.nix | 12 - bowl/mod-shaarli.nix | 80 ---- bowl/mod-wallabag.nix | 218 --------- bowl/monitoring.nix | 53 --- bowl/musician.nix | 24 - bowl/musnix.nix | 6 - bowl/navidrome.nix | 101 ---- bowl/networking.nix | 12 - bowl/nextcloud.nix | 52 --- bowl/nextcloud.nix.save.1 | 8 - bowl/nvim.nix | 262 ----------- bowl/pkg-navidrome.nix | 9 - bowl/pkg-rssBridge.nix | 30 -- bowl/pkg-shaarli.nix | 34 -- bowl/pkg-wallabag.nix | 39 -- bowl/shaarli-broken.nix | 78 ---- bowl/shaarli-docker.nix | 9 - bowl/shaarli-tokudan.nix | 97 ---- bowl/shaarli.nix | 116 ----- bowl/shiori.nix | 7 - bowl/taskd.nix | 12 - bowl/taskd.nix.save.1 | 9 - bowl/test-nginx.nix | 24 - bowl/unstable.nix | 13 - bowl/wallabag-data.patch | 31 -- bowl/wallabag-docker.nix | 52 --- bowl/wallabag.nix | 87 ---- bowl/wireguard.nix | 21 - bud/default.nix | 10 + bud/get.bash | 1 + default.nix | 31 ++ doc/.gitignore | 1 + doc/CONTRIBUTING.md | 18 + doc/SUMMARY.md | 28 ++ doc/book.toml | 6 + doc/bud/get.md | 10 + doc/bud/index.md | 24 + doc/concepts/hosts.md | 62 +++ doc/concepts/index.md | 10 + doc/concepts/overrides.md | 42 ++ doc/concepts/profiles.md | 67 +++ doc/concepts/suites.md | 25 + doc/concepts/users.md | 77 ++++ doc/integrations/cachix.md | 17 + doc/integrations/deploy.md | 49 ++ doc/integrations/hercules.md | 36 ++ doc/integrations/index.md | 5 + doc/integrations/nvfetcher.md | 43 ++ doc/outputs/index.md | 3 + doc/outputs/modules.md | 79 ++++ doc/outputs/overlays.md | 25 + doc/outputs/pkgs.md | 109 +++++ doc/secrets.md | 110 +++++ doc/start/bootstrapping.md | 102 +++++ doc/start/from-nixos.md | 54 +++ doc/start/index.md | 41 ++ doc/start/iso.md | 22 + doc/tests.md | 33 ++ doc/theme/highlight.js | 6 + flake.lock | 430 ++++++++++++++++++ flake.nix | 158 +++++++ hosts/NixOS.nix | 12 + hosts/bootstrap.nix | 18 + lib/compat/default.nix | 14 + lib/compat/nixos/default.nix | 10 + lib/default.nix | 2 + machines/bowl.nix | 74 --- machines/box.nix | 27 -- machines/helix.nix | 52 --- modules/backup.nix | 34 -- modules/common.nix | 114 ----- modules/dns.nix | 11 - modules/headphones.nix | 12 - modules/hm-system-defaults.nix | 11 + modules/matrix-slack.nix | 153 ------- modules/matrix.nix | 258 ----------- modules/mautrix-whatsapp.nix | 96 ---- modules/mod-shaarli.nix | 80 ---- modules/mod-wallabag.nix | 263 ----------- modules/monitoring-helix.nix | 17 - modules/monitoring.nix | 53 --- modules/navidrome.nix | 101 ---- modules/nextcloud.nix | 52 --- modules/nix-path.nix | 7 + modules/nvim.nix | 261 ----------- modules/sealight.nix | 14 - modules/shaarli.nix | 116 ----- modules/taskd.nix | 10 - modules/wireguard-helix.nix | 27 -- modules/wireguard.nix | 21 - nixos-legacy-bios-encrypted.sh | 104 ----- overlays/manix.nix | 5 + overlays/overrides.nix | 28 ++ overlays/various-flake-fixes.nix | 11 + pkgs/_sources/generated.nix | 16 + pkgs/default.nix | 5 + pkgs/pkg-navidrome.nix | 9 - pkgs/pkg-rssBridge.nix | 30 -- pkgs/pkg-shaarli.nix | 34 -- pkgs/pkg-wallabag.nix | 9 - pkgs/sources.toml | 4 + pkgs/unstable.nix | 13 - profiles/cachix/default.nix | 11 + profiles/cachix/nix-community.nix | 10 + profiles/cachix/nrdxp.nix | 10 + profiles/core/default.nix | 154 +++++++ profiles/core/starship.toml | 95 ++++ pull-nix-files-and-push.sh | 5 - reference/cozette.nix | 11 - reference/networking.nix | 12 - reference/shaarli-broken.nix | 78 ---- reference/shaarli-docker.nix | 9 - reference/shaarli-tokudan.nix | 97 ---- reference/shiori.nix | 7 - reference/test-nginx.nix | 24 - reference/wallabag-docker.nix | 52 --- reference/wallabag.nix | 120 ----- secrets/.gitattributes | 4 + secrets/secrets.nix | 9 + shell.nix | 1 + shell/default.nix | 10 + shell/devos.nix | 61 +++ shell/hooks/default.nix | 4 + shell/hooks/pre-commit.sh | 29 ++ .../modules/.flake-keep | 0 users/nixos/default.nix | 12 + users/profiles/direnv/default.nix | 9 + users/profiles/git/default.nix | 45 ++ users/root/default.nix | 5 + 137 files changed, 2574 insertions(+), 4145 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 COPYING create mode 100644 README.md create mode 100644 bors.toml delete mode 100644 bowl/backup.nix delete mode 100644 bowl/box.nix delete mode 100644 bowl/common.nix delete mode 100644 bowl/dns.nix delete mode 100644 bowl/headphones.nix delete mode 100644 bowl/mod-shaarli.nix delete mode 100644 bowl/mod-wallabag.nix delete mode 100644 bowl/monitoring.nix delete mode 100644 bowl/musician.nix delete mode 100644 bowl/musnix.nix delete mode 100644 bowl/navidrome.nix delete mode 100644 bowl/networking.nix delete mode 100644 bowl/nextcloud.nix delete mode 100644 bowl/nextcloud.nix.save.1 delete mode 100644 bowl/nvim.nix delete mode 100644 bowl/pkg-navidrome.nix delete mode 100644 bowl/pkg-rssBridge.nix delete mode 100644 bowl/pkg-shaarli.nix delete mode 100644 bowl/pkg-wallabag.nix delete mode 100644 bowl/shaarli-broken.nix delete mode 100644 bowl/shaarli-docker.nix delete mode 100644 bowl/shaarli-tokudan.nix delete mode 100644 bowl/shaarli.nix delete mode 100644 bowl/shiori.nix delete mode 100644 bowl/taskd.nix delete mode 100644 bowl/taskd.nix.save.1 delete mode 100644 bowl/test-nginx.nix delete mode 100644 bowl/unstable.nix delete mode 100644 bowl/wallabag-data.patch delete mode 100644 bowl/wallabag-docker.nix delete mode 100644 bowl/wallabag.nix delete mode 100644 bowl/wireguard.nix create mode 100644 bud/default.nix create mode 100644 bud/get.bash create mode 100644 default.nix create mode 100644 doc/.gitignore create mode 100644 doc/CONTRIBUTING.md create mode 100644 doc/SUMMARY.md create mode 100644 doc/book.toml create mode 100644 doc/bud/get.md create mode 100644 doc/bud/index.md create mode 100644 doc/concepts/hosts.md create mode 100644 doc/concepts/index.md create mode 100644 doc/concepts/overrides.md create mode 100644 doc/concepts/profiles.md create mode 100644 doc/concepts/suites.md create mode 100644 doc/concepts/users.md create mode 100644 doc/integrations/cachix.md create mode 100644 doc/integrations/deploy.md create mode 100644 doc/integrations/hercules.md create mode 100644 doc/integrations/index.md create mode 100644 doc/integrations/nvfetcher.md create mode 100644 doc/outputs/index.md create mode 100644 doc/outputs/modules.md create mode 100644 doc/outputs/overlays.md create mode 100644 doc/outputs/pkgs.md create mode 100644 doc/secrets.md create mode 100644 doc/start/bootstrapping.md create mode 100644 doc/start/from-nixos.md create mode 100644 doc/start/index.md create mode 100644 doc/start/iso.md create mode 100644 doc/tests.md create mode 100644 doc/theme/highlight.js create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/NixOS.nix create mode 100644 hosts/bootstrap.nix create mode 100644 lib/compat/default.nix create mode 100644 lib/compat/nixos/default.nix create mode 100644 lib/default.nix delete mode 100644 machines/bowl.nix delete mode 100644 machines/box.nix delete mode 100644 machines/helix.nix delete mode 100644 modules/backup.nix delete mode 100644 modules/common.nix delete mode 100644 modules/dns.nix delete mode 100644 modules/headphones.nix create mode 100644 modules/hm-system-defaults.nix delete mode 100644 modules/matrix-slack.nix delete mode 100644 modules/matrix.nix delete mode 100644 modules/mautrix-whatsapp.nix delete mode 100644 modules/mod-shaarli.nix delete mode 100644 modules/mod-wallabag.nix delete mode 100644 modules/monitoring-helix.nix delete mode 100644 modules/monitoring.nix delete mode 100644 modules/navidrome.nix delete mode 100644 modules/nextcloud.nix create mode 100644 modules/nix-path.nix delete mode 100644 modules/nvim.nix delete mode 100644 modules/sealight.nix delete mode 100644 modules/shaarli.nix delete mode 100644 modules/taskd.nix delete mode 100644 modules/wireguard-helix.nix delete mode 100644 modules/wireguard.nix delete mode 100644 nixos-legacy-bios-encrypted.sh create mode 100644 overlays/manix.nix create mode 100644 overlays/overrides.nix create mode 100644 overlays/various-flake-fixes.nix create mode 100644 pkgs/_sources/generated.nix create mode 100644 pkgs/default.nix delete mode 100644 pkgs/pkg-navidrome.nix delete mode 100644 pkgs/pkg-rssBridge.nix delete mode 100644 pkgs/pkg-shaarli.nix delete mode 100644 pkgs/pkg-wallabag.nix create mode 100644 pkgs/sources.toml delete mode 100644 pkgs/unstable.nix create mode 100644 profiles/cachix/default.nix create mode 100644 profiles/cachix/nix-community.nix create mode 100644 profiles/cachix/nrdxp.nix create mode 100644 profiles/core/default.nix create mode 100644 profiles/core/starship.toml delete mode 100755 pull-nix-files-and-push.sh delete mode 100644 reference/cozette.nix delete mode 100644 reference/networking.nix delete mode 100644 reference/shaarli-broken.nix delete mode 100644 reference/shaarli-docker.nix delete mode 100644 reference/shaarli-tokudan.nix delete mode 100644 reference/shiori.nix delete mode 100644 reference/test-nginx.nix delete mode 100644 reference/wallabag-docker.nix delete mode 100644 reference/wallabag.nix create mode 100644 secrets/.gitattributes create mode 100644 secrets/secrets.nix create mode 100644 shell.nix create mode 100644 shell/default.nix create mode 100644 shell/devos.nix create mode 100644 shell/hooks/default.nix create mode 100755 shell/hooks/pre-commit.sh rename bowl/taskd.nix.save => users/modules/.flake-keep (100%) create mode 100644 users/nixos/default.nix create mode 100644 users/profiles/direnv/default.nix create mode 100644 users/profiles/git/default.nix create mode 100644 users/root/default.nix diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..b8d9a688 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,114 @@ +# Changelog + +## [v0.10.0](https://github.com/divnix/devos/tree/v0.10.0) (2021-05-24) + +**Implemented enhancements:** + +- Providing an interface to nixpkgs.config [\#237](https://github.com/divnix/devos/issues/237) +- Making the user available in profiles [\#230](https://github.com/divnix/devos/issues/230) +- copy evaluation store paths to iso [\#195](https://github.com/divnix/devos/issues/195) +- Extract custom system builds from devosSystem out of lib [\#170](https://github.com/divnix/devos/issues/170) +- Allow setting of channel host-wide [\#117](https://github.com/divnix/devos/issues/117) +- alacritty: CSIu support [\#51](https://github.com/divnix/devos/issues/51) + +**Fixed bugs:** + +- Cachix timeouts + how to disable nrdxp cachix \(if needed\) [\#294](https://github.com/divnix/devos/issues/294) +- default.nix flake-compat is broken [\#285](https://github.com/divnix/devos/issues/285) +- All suites return "attribute missing" [\#282](https://github.com/divnix/devos/issues/282) +- nix is built two times [\#203](https://github.com/divnix/devos/issues/203) +- fix lib docs [\#166](https://github.com/divnix/devos/issues/166) + +**Closed issues:** + +- eliminate userFlakeNixOS [\#257](https://github.com/divnix/devos/issues/257) +- devos-as-library [\#214](https://github.com/divnix/devos/issues/214) + +**Merged pull requests:** + +- Update evalArgs to match the new planned API [\#239](https://github.com/divnix/devos/pull/239) + +## [v0.9.0](https://github.com/divnix/devos/tree/v0.9.0) (2021-04-19) + +**Implemented enhancements:** + +- pin inputs into iso live registry [\#190](https://github.com/divnix/devos/issues/190) +- Pass 'self' to lib [\#169](https://github.com/divnix/devos/issues/169) +- doc: quickstart "ISO. What next?" [\#167](https://github.com/divnix/devos/issues/167) +- Integrate Android AOSP putting mobile under control [\#149](https://github.com/divnix/devos/issues/149) +- Inoculate host identity on first use [\#132](https://github.com/divnix/devos/issues/132) +- kubenix support [\#130](https://github.com/divnix/devos/issues/130) +- Improve Home Manager support: profiles/suites, modules, extern, flake outputs [\#119](https://github.com/divnix/devos/issues/119) +- Local CA \(between hosts\) [\#104](https://github.com/divnix/devos/issues/104) +- Q5: git annex for machine state [\#68](https://github.com/divnix/devos/issues/68) +- name space ./pkgs overlays [\#60](https://github.com/divnix/devos/issues/60) +- remap global keys easily [\#57](https://github.com/divnix/devos/issues/57) +- make pass state part of this repo's structure [\#56](https://github.com/divnix/devos/issues/56) +- Incorporate ./shells [\#38](https://github.com/divnix/devos/issues/38) +- Encrypt with \(r\)age [\#37](https://github.com/divnix/devos/issues/37) + +**Fixed bugs:** + +- `pathsToImportedAttrs` does not accept directories [\#221](https://github.com/divnix/devos/issues/221) +- Cachix caches aren't added to the configuration [\#208](https://github.com/divnix/devos/issues/208) +- Issues with current changelog workflow [\#205](https://github.com/divnix/devos/issues/205) +- iso: systemd service startup [\#194](https://github.com/divnix/devos/issues/194) +- Help adding easy-hls-nix to devos [\#174](https://github.com/divnix/devos/issues/174) +- `flk update` fails because of obsolete flag [\#159](https://github.com/divnix/devos/issues/159) +- Expected that not all packages are exported? [\#151](https://github.com/divnix/devos/issues/151) +- Segmentation fault when generating iso [\#150](https://github.com/divnix/devos/issues/150) + +**Documentation:** + +- doc: split iso [\#193](https://github.com/divnix/devos/issues/193) +- lib: can depend on pkgs \(a la nixpkgs\#pkgs/pkgs-lib\) [\#147](https://github.com/divnix/devos/pull/147) + +**Closed issues:** + +- FRRouting router implementation [\#154](https://github.com/divnix/devos/issues/154) +- ARM aarch64 Support [\#72](https://github.com/divnix/devos/issues/72) + +## [v0.8.0](https://github.com/divnix/devos/tree/v0.8.0) (2021-03-02) + +**Implemented enhancements:** + +- semi automatic update for /pkgs [\#118](https://github.com/divnix/devos/issues/118) +- Home-manager external modules from flakes [\#106](https://github.com/divnix/devos/issues/106) + +**Fixed bugs:** + +- My emacsGcc overlay is not working [\#146](https://github.com/divnix/devos/issues/146) +- local flake registry freezes branches [\#142](https://github.com/divnix/devos/issues/142) +- nixos-option no longer works after collect garbage [\#138](https://github.com/divnix/devos/issues/138) +- Profiles imports are brittle, causing failure if imported twice [\#136](https://github.com/divnix/devos/issues/136) + +## [0.7.0](https://github.com/divnix/devos/tree/0.7.0) (2021-02-20) + +**Implemented enhancements:** + +- add zoxide [\#53](https://github.com/divnix/devos/issues/53) +- Multiarch support? [\#17](https://github.com/divnix/devos/issues/17) +- initial multiArch support [\#18](https://github.com/divnix/devos/pull/18) + +**Fixed bugs:** + +- Missing shebang from flk.sh [\#131](https://github.com/divnix/devos/issues/131) +- Rename Meta Issue [\#128](https://github.com/divnix/devos/issues/128) +- specialisations break the `system` argument [\#46](https://github.com/divnix/devos/issues/46) +- Revert "Add extraArgs to lib.nixosSystem call to add system args." [\#47](https://github.com/divnix/devos/pull/47) + +**Documentation:** + +- update home-manager urls [\#62](https://github.com/divnix/devos/pull/62) + +**Closed issues:** + +- add github action for cachix build ci [\#59](https://github.com/divnix/devos/issues/59) + +## [12052020](https://github.com/divnix/devos/tree/12052020) (2020-12-06) + +## [07092020](https://github.com/divnix/devos/tree/07092020) (2020-07-09) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..c9b44cb8 --- /dev/null +++ b/COPYING @@ -0,0 +1,18 @@ +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..6607bb42 --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +[![NixOS](https://img.shields.io/badge/NixOS-unstable-blue.svg?style=flat&logo=NixOS&logoColor=white)](https://nixos.org) +[![MIT License](https://img.shields.io/github/license/divnix/devos)][mit] +[![Chat](https://img.shields.io/matrix/devos:nixos.org.svg?label=%23devos%3Anixos.org&logo=matrix&server_fqdn=matrix.org)][matrix] + +> #### โš  Advisory โš  +> DevOS requires the [flakes][flakes] feature available via an _experimental_ +> branch of [nix][nix]. Until nix 2.4 is released, this project +> should be considered unstable. + +### Why? +Make an awesome template for NixOS users, with consideration for common tools like [home-manager][home-manager], +[devshell][devshell], and [more](./doc/integrations). + +### No. Why _flakes_? +Flakes are a part of an explicit push to improve [Nix's UX](https://github.com/NixOS/nix/blob/master/doc/manual/src/contributing/cli-guideline.md), and have become an integral part of that effort. + +They also make [Nix expressions](https://nixos.org/manual/nix/unstable/expressions/expression-syntax.html) easier to distribute and reuse with convient [flake references](https://github.com/NixOS/nix/blob/master/src/nix/flake.md#flake-references) for building or using packages, modules, and whole systems. + +## 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 via "[`digga`][digga]'s [`mkFlake`][mk-flake], +please file a bug report. + +### 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, and a [`develop`](https://github.com/divnix/devos/tree/develop) branch for the brave ๐Ÿ˜œ + +## In the Wild +* The original [authors][please] + +## 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] +- [`berberman/nvfetcher`][nvfetcher] +- [`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]. + +[community]: https://github.com/divnix/devos/tree/community +[core]: https://github.com/divnix/devos +[deploy]: https://github.com/serokell/deploy-rs +[devshell]: https://github.com/numtide/devshell +[digga]: https://github.com/divnix/digga +[dotfiles]: https://github.com/hlissner/dotfiles +[flake-doc]: https://github.com/NixOS/nix/blob/master/src/nix/flake.md +[flakes]: https://nixos.wiki/wiki/Flakes +[fu]: https://github.com/numtide/flake-utils +[fup]: https://github.com/gytis-ivaskevicius/flake-utils-plus +[giants]: https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants +[home-manager]: https://nix-community.github.io/home-manager +[mit]: https://mit-license.org +[mk-flake]: https://github.com/divnix/digga/tree/master/src/mkFlake +[nix]: https://nixos.org/manual/nix/stable +[nixos]: https://nixos.org/manual/nixos/stable +[nixpkgs]: https://github.com/NixOS/nixpkgs +[nvfetcher]: https://github.com/berberman/nvfetcher +[please]: https://github.com/nrdxp/devos/tree/nrd + diff --git a/bors.toml b/bors.toml new file mode 100644 index 00000000..6703d416 --- /dev/null +++ b/bors.toml @@ -0,0 +1,5 @@ +status = [ "check" ] + +required_approvals = 1 + +up_to_date_approvals = true diff --git a/bowl/backup.nix b/bowl/backup.nix deleted file mode 100644 index 8fa6f01c..00000000 --- a/bowl/backup.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - # Assumes the remote borg backup server has already been initialized - # borg init --encryption-key=repokey-blake2 -rsh 'ssh -i /run/keys/id_ed25519_borgbase' 20779@hk-s020.rsync.net: - services.borgbackup.jobs = { - backupTaskwarriorRsync = { - paths = [ "/var/lib/taskserver" ]; - doInit = true; - repo = "20779@hk-s020.rsync.net:taskwarrior" ; - encryption = { - mode = "repokey-blake2"; - passCommand = "cat /run/keys/rsync"; - }; - environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; - compression = "auto,lzma"; - startAt = "weekly"; - extraArgs = "--remote-path=borg1"; - }; - }; - services.borgbackup.jobs = { - backupShaarliRsync = { - paths = [ "/var/www/shaarli-config/data/datastore.php" "/var/www/shaarli-config/config" "/var/www/shaarli-config/.json.config" ]; - doInit = true; - repo = "20779@hk-s020.rsync.net:shaarli" ; - encryption = { - mode = "repokey-blake2"; - passCommand = "cat /run/keys/rsync"; - }; - environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; - compression = "auto,lzma"; - startAt = "weekly"; - extraArgs = "--remote-path=borg1"; - }; - }; -} diff --git a/bowl/box.nix b/bowl/box.nix deleted file mode 100644 index d7c291d3..00000000 --- a/bowl/box.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ./common.nix - ./musician.nix - ]; - - - users.extraUsers."anish".extraGroups = [ "jackaudio" ]; - - services.xserver = { - enable = true; - displayManager.gdm.enable = true; - desktopManager.gnome3.enable = true; - }; - - # task whisperer broken - #nixpkgs.config.allowBroken = true; - - # virtual box - virtualisation.virtualbox.host.enable = true; - - # ErgoDox Firmware (doesn't compile) - # environment.systemPackages = with pkgs; [ - # qmk_firmware - # ]; -} - diff --git a/bowl/common.nix b/bowl/common.nix deleted file mode 100644 index b9887b83..00000000 --- a/bowl/common.nix +++ /dev/null @@ -1,115 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ./nvim.nix -# ./unstable.nix - ]; - - - environment.systemPackages = with pkgs; [ - htop - iftop - wget - curl - exa - bat - fd - ag - tcpdump - whois - mtr - file - lsof - atool - inotify-tools - strace - zip - unzip - rsync - tmux - pwgen - glow - jq - gitAndTools.gitFull - #neovim defined in ./nvim.nix - wofi - firefox - fractal - pinentry_gnome - pass - gcc - less - mpv - zathura - #qmk_firmware - python3 - gdb - vcv-rack - #xdotool - #neofetch - #calibre - #openvpn - gimp - xxd - tilix - kitty - taskwarrior - gnupg - openjdk - glslviewer - filezilla - signal-desktop - wire-desktop - tdesktop - feedreader - newsflash - syncthing - dijo - #kdeconnect - #ssb-patchwork - gnome3.gnome-tweaks - gnome3.pomodoro - gnomeExtensions.gsconnect - #gnomeExtensions.taskwhisperer - #gnome3.networkmanager-openvpn - #python3Packages.youtube-dl - appimage-run - home-manager - libreoffice - fontconfig - hugo - #processing - #nextcloud-client - zsh-powerlevel10k - powerline-fonts - supercollider - haskellPackages.tidal - # vim-zettel - pandoc - ]; - - programs.bash.enableCompletion = true; - - # needed for vcv-rack - nixpkgs.config.allowUnfree = true; - - system.copySystemConfiguration = true; - services.syncthing = { - enable = true; - openDefaultPorts = true; - systemService = true; - user = "anish"; - dataDir = "/home/anish/usr/syncthing"; - }; - - #zsh powerlevel10k - programs.zsh.enable = true; - programs.zsh.promptInit = "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; - users.users.anish.shell = pkgs.zsh; - - #android - programs.adb.enable = true; - users.users.anish.extraGroups = ["adbusers"]; - -} diff --git a/bowl/dns.nix b/bowl/dns.nix deleted file mode 100644 index c9048718..00000000 --- a/bowl/dns.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, lib, ... }: -{ - services.dnsmasq.enable = false; - services.dnsmasq.extraConfig = '' - address=/.mossnet.lan/192.168.1.6 - dhcp-range=192.168.1.1,proxy - ''; - services.dnsmasq.servers = [ "45.90.30.49" "45.90.28.49" "1.1.1.1" "8.8.8.8" ]; - networking.firewall.allowedTCPPorts = [ 53 ]; - networking.firewall.allowedUDPPorts = [ 53 ]; -} diff --git a/bowl/headphones.nix b/bowl/headphones.nix deleted file mode 100644 index a76c6d5d..00000000 --- a/bowl/headphones.nix +++ /dev/null @@ -1,12 +0,0 @@ -{config, lib, pkgs, ... }: -{ - services.headphones = { - enable = true; - host = "192.168.1.6"; - port = 8181; - user = "headphones"; - group = "headphones"; - dataDir = "/data/downloaded"; - }; - networking.firewall.allowedTCPPorts = [ 8181 ]; -} diff --git a/bowl/mod-shaarli.nix b/bowl/mod-shaarli.nix deleted file mode 100644 index b3e0b52c..00000000 --- a/bowl/mod-shaarli.nix +++ /dev/null @@ -1,80 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - phppoolName = "shaarli"; - dataDir = "/var/lib/shaarli"; - vhost = "192.168.1.6:1233"; - - shaarli = pkgs.callPackage ./pkg-shaarli.nix { - inherit dataDir; - }; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "${shaarli}"; - listen = [ { addr = "192.168.1.6"; port = 1233; } ]; - # extraConfig = '' - # index index.php; - # ''; - locations."/" = { - index = "index.php"; - extraConfig = '' - try_files $uri $uri/ index.php; - ''; - }; - locations."~ (index)\.php$" = { - extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - include ${pkgs.nginx}/conf/fastcgi.conf; - fastcgi_pass unix:${config.services.phpfpm.pools."${phppoolName}".socket}; - fastcgi_index index.php; - ''; - }; - locations."~ \.php$" = { - extraConfig = '' - deny all; - ''; - }; - }; - services.phpfpm.pools."${phppoolName}" = { - user = "nginx"; - group = "nginx"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "nginx"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - }; - }; - users.extraUsers.shaarli = { group = "shaarli"; }; - users.extraGroups.shaarli = { }; - systemd.services.shaarli-install = { - serviceConfig.Type = "oneshot"; - wantedBy = [ "multi-user.target" ]; - script = '' - if [ ! -d "${dataDir}" ]; then - mkdir -p ${dataDir}/{cache,data,pagecache,tmp} - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/cache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/data/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/tmp/ - fi - chown -Rc nginx:nginx ${dataDir} - find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; - find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; - ''; - }; - - networking.firewall.allowedTCPPorts = [ 1233 ]; -} diff --git a/bowl/mod-wallabag.nix b/bowl/mod-wallabag.nix deleted file mode 100644 index cd7de9ce..00000000 --- a/bowl/mod-wallabag.nix +++ /dev/null @@ -1,218 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -let - cfg = config.services.wallabag; - - poolName = "wallabag"; - - configFile = pkgs.writeTextFile { - name = "wallabag-config"; - text = cfg.conf; - destination = "/config/parameters.yml"; - }; - - appDir = pkgs.buildEnv { - name = "wallabag-app-dir"; - ignoreCollisions = true; - checkCollisionContents = false; - paths = [ configFile "${cfg.package}/app" ]; - }; - -in { - options = { - services.wallabag = { - enable = mkEnableOption "wallabag"; - - user = mkOption { - type = types.str; - default = "nginx"; - description = '' - User account under which both the update daemon and the web-application run. - ''; - }; - - dataDir = mkOption { - type = types.path; - default = "/var/lib/wallabag"; - description = '' - Data directory. - ''; - }; - - package = mkOption { - type = types.package; - default = pkgs.wallabag; - description = '' - Wallabag package to use. - ''; - }; - - hostName = mkOption { - type = types.str; - description = '' - Name of the nginx virtualhost to use and setup. - ''; - }; - - poolConfig = mkOption { - type = types.lines; - default = '' - pm = dynamic - pm.max_children = 75 - pm.start_servers = 1 - pm.min_spare_servers = 1 - pm.max_spare_servers = 20 - pm.max_requests = 500 - catch_workers_output = 1 - ''; - description = '' - Options for wallabag's PHP pool. See the documentation on php-fpm.conf for details on configuration directives. - ''; - }; - - conf = mkOption { - type = types.str; - description = '' - Contents of the wallabag configuration file (parameters.yml) - ''; - }; - }; - }; - - - config = mkIf cfg.enable { - - services.phpfpm.pools."${poolName}" = { - user = "${cfg.user}"; - group = "nginx"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "listen.mode" = "0600"; - "user" = "${cfg.user}"; - "group" = "nginx"; - "env[WALLABAG_DATA]" = "${cfg.dataDir}"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - "php_admin_value[error_log]" = "/var/log/nginx/${poolName}-phpfpm-error.log"; - }; - }; - services.phpfpm.phpOptions = '' - max_execution_time = 120 - ''; - - services.nginx.enable = mkDefault true; - - services.nginx.virtualHosts."${cfg.hostName}" = { - enableACME = false; - forceSSL = false; - root = "${cfg.package}/web"; - - extraConfig = '' - add_header X-Frame-Options SAMEORIGIN; - add_header X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - ''; - - locations."/" = { - extraConfig = '' - try_files $uri /app.php$is_args$args; - ''; - }; - - locations."/assets".root = "${cfg.dataDir}/web"; - - locations."~ ^/app\\.php(/|$)" = { - extraConfig = '' - fastcgi_pass unix:${config.services.phpfpm.pools."${poolName}".socket}; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - - fastcgi_param SCRIPT_FILENAME ${cfg.package}/web/$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT ${cfg.package}/web; - fastcgi_read_timeout 120; - - fastcgi_param QUERY_STRING $query_string; - fastcgi_param REQUEST_METHOD $request_method; - fastcgi_param CONTENT_TYPE $content_type; - fastcgi_param CONTENT_LENGTH $content_length; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_param DOCUMENT_URI $document_uri; - fastcgi_param SERVER_PROTOCOL $server_protocol; - - fastcgi_param GATEWAY_INTERFACE CGI/1.1; - fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; - - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REMOTE_PORT $remote_port; - fastcgi_param SERVER_ADDR $server_addr; - fastcgi_param SERVER_PORT $server_port; - fastcgi_param SERVER_NAME $server_name; - - internal; - ''; - }; - - locations."~ /(?!app)\\.php$" = { - extraConfig = '' - return 404; - ''; - }; - }; - - systemd.services.wallabag-install = { - description = "Wallabag install service"; - wantedBy = [ "multi-user.target" ]; - before = [ "phpfpm-wallabag.service" ]; - after = [ "mysql.service" "postgresql.service" ]; - path = with pkgs; [ coreutils php phpPackages.composer ]; - - serviceConfig = { - User = cfg.user; - Type = "oneshot"; - RemainAfterExit = "yes"; - PermissionsStartOnly = true; - }; - - preStart = '' - mkdir -p "${cfg.dataDir}" - chown ${cfg.user}:nginx "${cfg.dataDir}" - ''; - - script = '' - echo "Setting up wallabag files in ${cfg.dataDir} ..." - cd "${cfg.dataDir}" - - rm -rf var/cache/* - rm -f app - ln -sf ${appDir} app - ln -sf ${cfg.package}/composer.{json,lock} . - - export WALLABAG_DATA="${cfg.dataDir}" - if [ ! -f installed ]; then - php ${cfg.package}/bin/console --env=prod doctrine:database:create --if-not-exists --no-interaction - php ${cfg.package}/bin/console --env=prod doctrine:migrations:migrate --no-interaction - # Until https://github.com/wallabag/wallabag/issues/3662 is fixed - # yes no | php ${cfg.package}/bin/console --env=prod wallabag:install - touch installed - else - php ${cfg.package}/bin/console --env=prod doctrine:migrations:migrate --no-interaction - fi - php ${cfg.package}/bin/console --env=prod cache:clear - ''; - }; - }; - - meta = with stdenv.lib; { - maintainers = with maintainers; [ nadrieril ]; - }; -} diff --git a/bowl/monitoring.nix b/bowl/monitoring.nix deleted file mode 100644 index c5683289..00000000 --- a/bowl/monitoring.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ config, pkgs, ... }: { - # grafana configuration - services.grafana = { - enable = true; - domain = "grafana.mossnet.lan"; - port = 2342; - addr = "127.0.0.1"; - }; - - # nginx reverse proxy - services.nginx.virtualHosts.${config.services.grafana.domain} = { - locations."/" = { - proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}"; - proxyWebsockets = true; - }; - }; - - services.prometheus = { - enable = true; - port = 9001; - exporters = { - node = { - enable = true; - enabledCollectors = [ "systemd" ]; - port = 9002; - }; - }; - scrapeConfigs = [ - { - job_name = "bowl"; - static_configs = [{ - targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; - }]; - } - ]; - }; - - services.loki = { - enable = true; - configFile = /var/loki-config.yaml; - }; - - systemd.services.promtail = { - description = "Promtail service for Loki"; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - ExecStart = '' - ${pkgs.grafana-loki}/bin/promtail --config.file ${/var/promtail.yaml} - ''; - }; - }; -} diff --git a/bowl/musician.nix b/bowl/musician.nix deleted file mode 100644 index 0dc95059..00000000 --- a/bowl/musician.nix +++ /dev/null @@ -1,24 +0,0 @@ -{pkgs, config, ... }: -{ - imports = [ - /home/anish/usr/musnix - ]; - - musnix.enable = true; - users.users.anish.extraGroups = [ "audio" ]; - - environment.systemPackages = with pkgs; [ ardour patchage helm ]; - #services.jack = { - # jackd.enable = true; - # # support ALSA only programs via ALSA JACK PCM plugin - # alsa.enable = false; - # # support ALSA only programs via loopback device (supports programs like Steam) - # loopback = { - # enable = true; - # # buffering parameters for dmix device to work with ALSA only semi-professional sound programs - # #dmixConfig = '' - # # period_size 2048 - # #''; - # }; - #}; -} diff --git a/bowl/musnix.nix b/bowl/musnix.nix deleted file mode 100644 index b924f30f..00000000 --- a/bowl/musnix.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ ]; - musnix.enable = true; - - users.users."anish".extraGroups = [ "audio" ]; -} diff --git a/bowl/navidrome.nix b/bowl/navidrome.nix deleted file mode 100644 index be4fe9c5..00000000 --- a/bowl/navidrome.nix +++ /dev/null @@ -1,101 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.services.navidrome; - configFile = "/etc/navidrome/settings.json"; - dataFolder = "/var/lib/navidrome"; -in { - options = { - - services.navidrome = { - enable = mkEnableOption "Navidrome music server and streamer"; - - settings = lib.mkOption { - type = with types; attrsOf (oneOf [ int str ]); - default = {}; - example = literalExample '' - { - LogLevel = "INFO"; - BaseURL = "/music"; - ScanInterval = "10s"; - TranscodingCacheSize = "15MB"; - MusicFolder = "/data/music"; - }; - ''; - description = '' - Configuration for Navidrome, see for supported values. - ''; - }; - - user = mkOption { - type = types.str; - default = "navidrome"; - description = "User account under which Navidrome runs."; - }; - - group = mkOption { - type = types.str; - default = "navidrome"; - description = "Group account under which Navidrome runs."; - }; - - }; - }; - - config = mkIf cfg.enable { - - environment.etc."navidrome/settings.json".text = builtins.toJSON cfg.settings; - - services.navidrome.settings = { - DataFolder = dataFolder; - ConfigFile = configFile; - }; - - systemd.services.navidrome = { - description = "Navidrome Music Server and Streamer compatible with Subsonic/Airsonic"; - after = [ "remote-fs.target" "network.target" ]; - wantedBy = [ "multi-user.target" ]; - environment = { - ND_CONFIGFILE = configFile; - }; - serviceConfig = { - ExecStart = "${pkgs.navidrome}/bin/navidrome"; - WorkingDirectory = dataFolder; - TimeoutStopSec = "20"; - KillMode = "process"; - Restart = "on-failure"; - User = cfg.user; - Group = cfg.group; - DevicePolicy = "closed"; - NoNewPrivileges= " yes"; - PrivateTmp = "yes"; - PrivateUsers = "yes"; - ProtectControlGroups = "yes"; - ProtectKernelModules = "yes"; - ProtectKernelTunables = "yes"; - RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6"; - RestrictNamespaces = "yes"; - RestrictRealtime = "yes"; - SystemCallFilter = "~@clock @debug @module @mount @obsolete @privileged @reboot @setuid @swap"; - ReadWritePaths = dataFolder; - StateDirectory = baseNameOf dataFolder; - }; - }; - - users.users = optionalAttrs (cfg.user == "navidrome") ({ - navidrome = { - description = "Navidrome service user"; - name = cfg.user; - group = cfg.group; - isSystemUser = true; - }; - }); - - users.groups = optionalAttrs (cfg.group == "navidrome") ({ - navidrome = {}; - }); - - }; -} diff --git a/bowl/networking.nix b/bowl/networking.nix deleted file mode 100644 index c7c7c06a..00000000 --- a/bowl/networking.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, ... }: -{ - #networking.interfaces.enp3s0.ipv4.addresses = [ { - #address = "192.168.1.6"; - #prefixLength = 24; - #} ]; - networking.nameservers = [ "1.1.1.1" ]; - #networking.defaultGateway = "192.168.1.1"; - environment.systemPackages = [ pkgs.mosh ]; - programs.mosh.enable = true; - #config.nssDatabase.hosts = [ "mdns_minimal" "[NOTFOUND=return]" ]; -} diff --git a/bowl/nextcloud.nix b/bowl/nextcloud.nix deleted file mode 100644 index c1919b80..00000000 --- a/bowl/nextcloud.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ pkgs, config, ... }: -{ - services.nextcloud = { - enable = true; - hostName = "mossnet.lan"; - #home = "/data/nextcloud"; - - # Use HTTPS for links - https = false; - - # Auto-update Nextcloud Apps - autoUpdateApps.enable = true; - # Set what time makes sense for you - autoUpdateApps.startAt = "05:00:00"; - - config = { - # Further forces Nextcloud to use HTTPS - # overwriteProtocol = "https"; - - # Nextcloud PostegreSQL database configuration, recommended over using SQLite - dbtype = "pgsql"; - dbuser = "nextcloud"; - dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself - dbname = "nextcloud"; - dbpassFile = "/var/nextcloud-db-pass"; - - adminpassFile = "/var/nextcloud-admin-pass"; - adminuser = "admin"; - }; - }; - - # Enable PostgreSQL - services.postgresql = { - enable = true; - - # Ensure the database, user, and permissions always exist - ensureDatabases = [ "nextcloud" ]; - ensureUsers = [ - { name = "nextcloud"; - ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; - } - ]; - }; - - # Ensure that postgres is running before running the setup - systemd.services."nextcloud-setup" = { - requires = ["postgresql.service"]; - after = ["postgresql.service"]; - }; - - networking.firewall.allowedTCPPorts = [ 80 443 ]; -} diff --git a/bowl/nextcloud.nix.save.1 b/bowl/nextcloud.nix.save.1 deleted file mode 100644 index cd28966c..00000000 --- a/bowl/nextcloud.nix.save.1 +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs, config, ... }: -{ - security.acme = { - acceptTerms = true; - # Replace the email here! - email = "anish@lakhwara.com"; - }; -} diff --git a/bowl/nvim.nix b/bowl/nvim.nix deleted file mode 100644 index f7319d73..00000000 --- a/bowl/nvim.nix +++ /dev/null @@ -1,262 +0,0 @@ -{ pkgs, ... }: - - - #nvim - { - environment.variables.EDITOR = "nvim"; - environment.shellAliases = { - k = "vim -c :VimwikiIndex"; - kz = "vim -c :VimwikiIndex -c :ZettelNew"; - }; - environment.systemPackages = with pkgs; [ - nodejs - ( neovim.override { - vimAlias = true; - configure = { - packages.myPlugins = with pkgs.vimPlugins; { - start = [ - vim-nix - fzf-vim - vim-elixir - emmet-vim - nerdtree - goyo-vim - vim-sneak - lightline-vim - csv-vim - vimwiki - coc-nvim - coc-json - coc-python - coc-pairs - coc-emmet - emmet-vim - LanguageClient-neovim - ayu-vim - rainbow_parentheses-vim - vim-surround - vim-fugitive - #iron-nvim - #nvim-colorizer - vim-devicons - - # testing - #vim-processing - #vim-tidal - taskwiki - vim-zettel - vimwiki-sync - ]; - }; - customRC = '' - set tabstop=2 - set showmatch - set shiftwidth=2 - set noexpandtab - set autoindent - - set foldmethod=indent " fold based on indent - set number - set nocompatible - set relativenumber - set showtabline=2 - set autowriteall - syntax on - set list lcs=tab:\|\ - filetype plugin on - - set termguicolors - let ayucolor="dark" - colorscheme ayu - - " window - nmap wh :topleft vnew - nmap wl :botright vnew - nmap wk :topleft new - nmap wj :botright new - - let mapleader = "\" - - " lightline colorscheme - let g:lightline = { - \ 'colorscheme': 'seoul256', - \ } - - " moving splits with vim movements. - :tnoremap h - :tnoremap j - :tnoremap k - :tnoremap l - :inoremap h - :inoremap j - :inoremap k - :inoremap l - :nnoremap h - :nnoremap j - :nnoremap k - :nnoremap l - :nnoremap "=strftime("%Y-%m-%d %H:%M:") - :inoremap =strftime("%Y-%m-%d %H:%M:") - - " exit normal mode in terminal - :tnoremap - - let g:syntastic_always_populate_loc_list = 1 - let g:syntastic_auto_loc_list = 1 - let g:syntastic_check_on_open = 1 - let g:syntastic_check_on_wq = 0 - - let g:rainbow_active = 0 - autocmd BufReadPost,BufNewFile c,py,nix RainbowParenthesesToggleAll - - " keyboard commands - map t :NERDTreeToggle - map s :w - map q :wq - map r :RainbowParenthesesToggleAll - map zs :ZettelSearch - map zo :ZettelOpen - map zn :ZettelNew - - - " NERDTree - " open on directory - autocmd StdinReadPre * let s:std_in=1 - - " coc - " - " if hidden is not set, TextEdit might fail. - set hidden - - " Some servers have issues with backup files, see #649 - set nobackup - set nowritebackup - - " Better display for messages - set cmdheight=2 - - " You will have bad experience for diagnostic messages when it's default 4000. - set updatetime=300 - - " don't give |ins-completion-menu| messages. - set shortmess+=c - - " always show signcolumns - set signcolumn=yes - - " Use tab for trigger completion with characters ahead and navigate. - " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. - inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() - inoremap pumvisible() ? "\" : "\" - - function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' - endfunction - - " Use to trigger completion. - inoremap coc#refresh() - - " Use to confirm completion, `u` means break undo chain at current position. - " Coc only does snippet and additional edit on confirm. - inoremap pumvisible() ? "\" : "\u\" - " Or use `complete_info` if your vim support it, like: - " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - - " Use `[g` and `]g` to navigate diagnostics - nmap [g (coc-diagnostic-prev) - nmap ]g (coc-diagnostic-next) - - " Remap keys for gotos - nmap gd (coc-definition) - nmap gy (coc-type-definition) - nmap gi (coc-implementation) - nmap gr (coc-references) - - " Use K to show documentation in preview window - nnoremap K :call show_documentation() - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif - endfunction - - " Highlight symbol under cursor on CursorHold - autocmd CursorHold * silent call CocActionAsync('highlight') - - " Remap for rename current word - nmap rn (coc-rename) - - " Remap for format selected region - xmap f (coc-format-selected) - nmap f (coc-format-selected) - - augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') - augroup end - - " Remap for do codeAction of selected region, ex: `aap` for current paragraph - xmap a (coc-codeaction-selected) - nmap a (coc-codeaction-selected) - - " Remap for do codeAction of current line - nmap ac (coc-codeaction) - " Fix autofix problem of current line - nmap qf (coc-fix-current) - - " Create mappings for function text object, requires document symbols feature of languageserver. - xmap if (coc-funcobj-i) - xmap af (coc-funcobj-a) - omap if (coc-funcobj-i) - omap af (coc-funcobj-a) - - " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python - nmap (coc-range-select) - xmap (coc-range-select) - - " Use `:Format` to format current buffer - command! -nargs=0 Format :call CocAction('format') - - " Use `:Fold` to fold current buffer - command! -nargs=? Fold :call CocAction('fold', ) - - " use `:OR` for organize import of current buffer - command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - - " Add status line support, for integration with other plugin, checkout `:h coc-status` - " set statusline^=%{coc#status()}%{get(b:,'coc_current_function',"")} - - " Using CocList - " Show all diagnostics - nnoremap a :CocList diagnostics - " Manage extensions - nnoremap e :CocList extensions - " Show commands - nnoremap c :CocList commands - " Find symbol of current document - nnoremap o :CocList outline - " Search workspace symbols - nnoremap s :CocList -I symbols - " Do default action for next item. - nnoremap j :CocNext - " Do default action for previous item. - nnoremap k :CocPrev - " Resume latest coc list - nnoremap p :CocListResume - - au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl setf glsl - ''; - }; - } - )]; -} diff --git a/bowl/pkg-navidrome.nix b/bowl/pkg-navidrome.nix deleted file mode 100644 index 5bcd3789..00000000 --- a/bowl/pkg-navidrome.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, lib, pkgs, ... }: -{ - services.navidrome.enable = true; - services.navidrome.settings = { - MusicFolder = "/data/music"; - Port = 4433; - }; - networking.firewall.allowedTCPPorts = [ 4433 ]; -} diff --git a/bowl/pkg-rssBridge.nix b/bowl/pkg-rssBridge.nix deleted file mode 100644 index e606c187..00000000 --- a/bowl/pkg-rssBridge.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib, stdenv, fetchurl, config ? null, dataDir ? "/var/lib/shaarli" }: - -stdenv.mkDerivation rec { - name = "rssBridge-${version}"; - version = "2020-10-11"; - preferLocalBuild = true; - - src = fetchurl { - url = "https://github.com/RSS-Bridge/rss-bridge/archive/${version}.tar.gz"; - sha256 = ""; - }; - - phases = [ "installPhase" ]; - installPhase = '' - mkdir $out - tar xzf $src - cp -ra * $out/ - find $out -type d -exec chmod 0755 {} \; - find $out -type f -exec chmod 0644 {} \; - ln -s $dataDir $out - ''; - - meta = with stdenv.lib; { - description = "RSS-Bridge is a project to create RSS Feeds for websites that don't have one."; - #license = licenses.agpl3; - homepage = "https://github.com/RSS-Bridge/rss-bridge/"; - platforms = platforms.all; - maintainers = with stdenv.lib.maintainers; [ chickensoupwithrice ]; - }; -} diff --git a/bowl/pkg-shaarli.nix b/bowl/pkg-shaarli.nix deleted file mode 100644 index be780707..00000000 --- a/bowl/pkg-shaarli.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ lib, stdenv, fetchurl, config ? null, dataDir ? "/var/lib/shaarli" }: - -stdenv.mkDerivation rec { - name = "shaarli-${version}"; - version = "0.11.1"; - preferLocalBuild = true; - - src = fetchurl { - url = "https://github.com/shaarli/Shaarli/releases/download/v0.11.1/shaarli-v${version}-full.tar.gz"; - sha256 = "1psijcmi24hk0gxh1zdsm299xj11i7find2045nnx3r96cgnwjpn"; - }; - - phases = [ "installPhase" ]; - installPhase = '' - mkdir $out - tar xzf $src - cp -ra Shaarli/. $out/ - find $out -type d -exec chmod 0755 {} \; - find $out -type f -exec chmod 0644 {} \; - for a in cache data pagecache tmp; do - mv $out/$a $out/$a.orig - ln -s "${dataDir}/$a" $out/$a - done - ''; - - meta = with stdenv.lib; { - description = ""; - # License is complicated... - #license = licenses.agpl3; - homepage = "https://github.com/shaarli/Shaarli"; - platforms = platforms.all; - maintainers = with stdenv.lib.maintainers; [ tokudan ]; - }; -} diff --git a/bowl/pkg-wallabag.nix b/bowl/pkg-wallabag.nix deleted file mode 100644 index e82c6c39..00000000 --- a/bowl/pkg-wallabag.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ stdenv, fetchurl }: - -stdenv.mkDerivation rec { - pname = "wallabag"; - version = "2.4.0"; - - # remember to rm -r var/cache/* after a rebuild or unexpected errors will occur - - src = fetchurl { - url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz"; - sha256 = "11vda7aqq82kpr88v4hr7zg19zfq970n3z4qp25my8b1fvlgdjhi"; - }; - - outputs = [ "out" ]; - - patches = [ - ./wallabag-data.patch # exposes $WALLABAG_DATA - ]; - - dontBuild = true; - - installPhase = '' - mkdir $out/ - cp -R * $out/ - ''; - - meta = with stdenv.lib; { - description = "Web page archiver"; - longDescription = '' - wallabag is a self hostable application for saving web pages. - Point the environment variable $WALLABAG_DATA to a data directory that contains the folder `app/config` which must be a clone of wallabag's configuration files with your customized `parameters.yml`. These need to be updated every package upgrade. - After a package upgrade, empty the `var/cache` folder. - ''; - license = licenses.mit; - homepage = "http://wallabag.org"; - maintainers = with maintainers; [ schneefux ]; - platforms = platforms.all; - }; -} diff --git a/bowl/shaarli-broken.nix b/bowl/shaarli-broken.nix deleted file mode 100644 index 1541149c..00000000 --- a/bowl/shaarli-broken.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ config, pkgs, ... }: -let - app = "shaarli"; - dataDir = "/var/www/${app}"; -in { - services.nginx = { - enable = true; - virtualHosts = { - "192.168.1.6:1232" = { - forceSSL = false; - enableACME = false; - #root = pkgs.shaarli; - root = dataDir; - listen = [ { addr = "192.168.1.6"; port = 1232; } ]; - extraConfig = '' - index index.php; - ''; - locations = { - "/".index = "index.php"; - - "~ /\\.".extraConfig = '' - log_not_found off; - deny all; - ''; - - "~ (index)\\.php$".extraConfig = '' - try_files $uri =404 - include ${pkgs.nginx}/conf/fastcgi.conf; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SHAARLI_CONFIG /var/www/shaarli/config; - - fastcgi_pass unix:${config.services.phpfpm.pools.${app}.socket}; - fastcgi_index index.php; - ''; - - "^~ /tpl/".extraConfig = "alias ${pkgs.shaarli}/tpl/;"; - - "~ \\.php$".extraConfig = '' - deny all; - ''; - - "^~ /plugins/".extraConfig = "alias ${pkgs.shaarli}/plugins/;"; - - "~* \\.(?:ico|css|js|gif|jpe?g|png)$".extraConfig = '' - expires max; - add_header Pragma public; - add_header Cache-Control "public, must-revalidate, proxy-revalidate"; - ''; - }; - }; - }; - }; - services.phpfpm.pools.${app} = { - user = app; - #listen = "/run/phpfpm/shaarli.sock"; - settings = { - "listen.owner" = config.services.nginx.user; - "pm" = "dynamic"; - "pm.max_children" = 4; - "pm.start_servers" = 2; - "pm.min_spare_servers" = 1; - "pm.max_spare_servers" = 4; - "pm.max_requests" = 32; - "php_admin_value[error_log]" = "stderr"; - "php_admin_flag[log_errors]" = true; - }; - }; - systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ]; - users.users.${app} = { - isSystemUser = true; - createHome = true; - home = dataDir; - group = app; - }; - users.groups.${app} = {}; - networking.firewall.allowedTCPPorts = [ 1232 ]; -} diff --git a/bowl/shaarli-docker.nix b/bowl/shaarli-docker.nix deleted file mode 100644 index f2193fcf..00000000 --- a/bowl/shaarli-docker.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkg, config, lib, ... }: -{ - docker-containers."shaarli" = { - image = "shaarli/shaarli"; - volumes = [ "shaarli:/var/lib/shaarli/data/" ]; - ports = [ "1233:80" ]; - }; - networking.firewall.allowedTCPPorts = [ 1233 ]; -} diff --git a/bowl/shaarli-tokudan.nix b/bowl/shaarli-tokudan.nix deleted file mode 100644 index 8a3c3fca..00000000 --- a/bowl/shaarli-tokudan.nix +++ /dev/null @@ -1,97 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - phppoolName = "shaarli"; - dataDir = "/var/lib/shaarli"; - vhost = "192.168.1.6:1232"; - - shaarli = pkgs.callPackage ./pkg-shaarli.nix { - inherit dataDir; - }; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "${dataDir}"; - listen = [ { addr = "192.168.1.6"; port = 1232; } ]; - extraConfig = '' - index index.php; - ''; - locations."/" = { - extraConfig = '' - try_files _ /index.php$is_args$args;"; - ''; - }; - locations."~ (index)\\.php$" = { - extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - fastcgi_pass unix:${config.services.phpfpm.pools.shaarli.socket}; - fastcgi_index index.php; - - fastcgi_param QUERY_STRING $query_string; - fastcgi_param REQUEST_METHOD $request_method; - fastcgi_param CONTENT_TYPE $content_type; - fastcgi_param CONTENT_LENGTH $content_length; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_param DOCUMENT_URI $document_uri; - fastcgi_param DOCUMENT_ROOT $document_root; - fastcgi_param SERVER_PROTOCOL $server_protocol; - - fastcgi_param GATEWAY_INTERFACE CGI/1.1; - fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; - - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REMOTE_PORT $remote_port; - fastcgi_param SERVER_ADDR $server_addr; - fastcgi_param SERVER_PORT $server_port; - fastcgi_param SERVER_NAME $server_name; - - fastcgi_param HTTPS $https; - ''; - }; - }; - services.phpfpm.pools.shaarli = { - user = "shaarli"; - group = "shaarli"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "shaarli"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - }; - }; - users.extraUsers.shaarli = { group = "shaarli"; home = dataDir; }; - users.extraGroups.shaarli = { }; - systemd.services.shaarli-install = { - serviceConfig.Type = "oneshot"; - wantedBy = [ "multi-user.target" ]; - script = '' - if [ ! -d "${dataDir}" ]; then - mkdir -p ${dataDir}/{cache,data,pagecache,tmp} - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/cache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/data/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/tmp/ - fi - chown -Rc shaarli:shaarli ${dataDir} - find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; - find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; - ''; - }; - networking.firewall.allowedTCPPorts = [ 1232 ]; -} diff --git a/bowl/shaarli.nix b/bowl/shaarli.nix deleted file mode 100644 index b9afd461..00000000 --- a/bowl/shaarli.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ pkgs, config, ... }: -let - dataDir = "/var/www/shaarli-config"; - name = "shaarli"; -in -{ - services.nginx = { - enable = true; - virtualHosts = { - "links.mossnet.lan" = { - forceSSL = false; - enableACME = false; - root = "${dataDir}"; - #listen = [ { addr = "192.168.1.6"; port = 1234; } ]; - extraConfig = '' - index index.php; - ''; - locations = { - "/".extraConfig = '' - try_files $uri $uri/ index.php; - ''; - - "~ (index)\.php$".extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - fastcgi_pass unix:${config.services.phpfpm.pools."${name}".socket}; - fastcgi_index index.php; - - fastcgi_param QUERY_STRING $query_string; - fastcgi_param REQUEST_METHOD $request_method; - fastcgi_param CONTENT_TYPE $content_type; - fastcgi_param CONTENT_LENGTH $content_length; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_param DOCUMENT_URI $document_uri; - fastcgi_param DOCUMENT_ROOT $document_root; - fastcgi_param SERVER_PROTOCOL $server_protocol; - - fastcgi_param GATEWAY_INTERFACE CGI/1.1; - fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; - - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REMOTE_PORT $remote_port; - fastcgi_param SERVER_ADDR $server_addr; - fastcgi_param SERVER_PORT $server_port; - fastcgi_param SERVER_NAME $server_name; - ''; - - "~ \.php$".extraConfig = '' - deny all; - ''; - - "^~ /tpl/".extraConfig = "alias ${pkgs.shaarli}/tpl/;"; - - "^~ /plugins/".extraConfig = "alias ${pkgs.shaarli}/plugins/;"; - - "~* \\.(?:ico|css|js|gif|jpe?g|png)$".extraConfig = '' - expires max; - add_header Pragma public; - add_header Cache-Control "public, must-revalidate, proxy-revalidate"; - ''; - }; - }; - }; - }; - - services.phpfpm = { - pools = { - "${name}" = { - user = "nginx"; - group = "nginx"; - #listen = "/run/phpfpm/php.sock"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "nginx"; - "pm" = "dynamic"; - "pm.max_children" = "4"; - "pm.min_spare_servers" = "1"; - "pm.max_spare_servers" = "4"; - "pm.max_requests" = "32"; - "catch_workers_output" = "1"; - "php_admin_value[error_log]" = "/var/log/nginx/${name}-phpfpm-error.log"; - }; - }; - }; - }; - users.extraUsers."${name}" = { group = "${name}"; }; - users.extraGroups."${name}" = { }; - systemd.services.shaarli-install = { - serviceConfig.Type = "oneshot"; - wantedBy = [ "multi-user.target" ]; - script = '' - if [ ! -d "${dataDir}" ]; then - mkdir -p ${dataDir}/{cache,data,pagecache,tmp} - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/cache/ - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/data/ - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/tmp/ - ln -S ${pkgs.shaarli}/* ${dataDir} - fi - chown -Rc nginx:nginx ${dataDir} - find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; - find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; - ''; - }; - # TODO: Write the configuration file here? - #networking.firewall.allowedTCPPorts = [ 1234 ]; -} diff --git a/bowl/shiori.nix b/bowl/shiori.nix deleted file mode 100644 index a1dfde45..00000000 --- a/bowl/shiori.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, config, lib, ... }: -{ - services.shiori.enable = true; - services.shiori.address = "192.168.1.6"; - services.shiori.port = 1234; - networking.firewall.allowedTCPPorts = [ 1234 ]; -} diff --git a/bowl/taskd.nix b/bowl/taskd.nix deleted file mode 100644 index 94c4a3b6..00000000 --- a/bowl/taskd.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, ... }: - -{ - services.taskserver.enable = true; - #services.taskserver.fqdn = "192.168.1.6"; - #services.taskserver.listenHost = "192.168.1.6"; - services.taskserver.fqdn = "172.16.11.242"; - services.taskserver.listenHost = "172.16.11.242"; - services.taskserver.listenPort = 53589; - services.taskserver.organisations.mossnet.users = [ "anish" ]; -} - diff --git a/bowl/taskd.nix.save.1 b/bowl/taskd.nix.save.1 deleted file mode 100644 index 22087794..00000000 --- a/bowl/taskd.nix.save.1 +++ /dev/null @@ -1,9 +0,0 @@ -{ config, pkgs, ... }: - -{ - services.taskserver.enable = true; - services.taskserver.fqdn = "bowl"; - services.taskserver.listenHost = "::"; - services.taskserver.organisations.mossnet.users = [ "anish" ]; -} - diff --git a/bowl/test-nginx.nix b/bowl/test-nginx.nix deleted file mode 100644 index 69c480f2..00000000 --- a/bowl/test-nginx.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - vhost = "192.168.1.6:1232"; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "/var/lib/test"; - listen = [ { addr = "192.168.1.6"; port = 1232; } ]; - extraConfig = '' - index index.html; - ''; - - locations."/" = { - extraConfig = '' - try_files $uri $uri/ index.html; - ''; - }; - }; - - networking.firewall.allowedTCPPorts = [ 1232 ]; -} diff --git a/bowl/unstable.nix b/bowl/unstable.nix deleted file mode 100644 index 983a4ed8..00000000 --- a/bowl/unstable.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, pkgs, ... }: - - -let - unstable = import {}; -in { - nix.nixPath = [ - "nixos-unstable=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz" - ]; - - #currently installed this software through nix-env -f https://nixos.org/channels/nixos-unstable -iA [ packages ] - environment.systemPackages = [ unstable.ripcord ]; -} diff --git a/bowl/wallabag-data.patch b/bowl/wallabag-data.patch deleted file mode 100644 index 243569b4..00000000 --- a/bowl/wallabag-data.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/app/AppKernel.php b/app/AppKernel.php -index 347197e..902b558 100644 ---- a/app/AppKernel.php -+++ b/app/AppKernel.php -@@ -69,19 +69,24 @@ class AppKernel extends Kernel - return __DIR__; - } - -+ public function getProjectDir() -+ { -+ return getenv('WALLABAG_DATA') ?: dirname(__DIR__); -+ } -+ - public function getCacheDir() - { -- return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment(); -+ return $this->getProjectDir() . '/var/cache/' . $this->getEnvironment(); - } - - public function getLogDir() - { -- return dirname(__DIR__) . '/var/logs'; -+ return $this->getProjectDir() . '/var/logs'; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { -- $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); -+ $loader->load($this->getProjectDir() . '/app/config/config_' . $this->getEnvironment() . '.yml'); - - $loader->load(function ($container) { diff --git a/bowl/wallabag-docker.nix b/bowl/wallabag-docker.nix deleted file mode 100644 index 4bd844a1..00000000 --- a/bowl/wallabag-docker.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ pkg, config, lib, ... }: -{ - docker-containers."wallabag-db" = { - image = "postgres"; - environment = { - "POSTGRES_PASSWORD" = "wallaroot"; - "POSTGRES_USER" = "postgres"; - }; - extraDockerOptions = [ "--network=wallabag-br" ]; - volumes = [ "/opt/wallabag/data:/var/www/wallabag" ]; - }; - - docker-containers."wallabag" = { - image = "wallabag/wallabag"; - ports = [ "800:80" ]; - #volumes = [ "/opt/wallabag/data:/var/www/wallabag/data" "/opt/wallabag/images:/var/www/wallabag/web/assets/images" ]; - environment = { - "SYMFONY__ENV__DOMAIN_NAME" = "http://192.168.1.6:800"; - "POSTGRES_PASSWORD" = "wallaroot"; - "POSTGRES_USER" = "postgres"; - "SYMFONY__ENV__DATABASE_DRIVER" = "pdo_pgsql"; - "SYMFONY__ENV__DATABASE_DRIVER_CLASS" = "Wallabag\\CoreBundle\\Doctrine\\DBAL\\Driver\\CustomPostgreSQLDriver"; - "SYMFONY__ENV__DATABASE_HOST" = "wallabag-db"; - "SYMFONY__ENV__DATABASE_PORT" = "5432"; - "SYMFONY__ENV__DATABASE_NAME" = "wallabag"; - "SYMFONY__ENV__DATABASE_USER" = "wallabag"; - "SYMFONY__ENV__DATABASE_PASSWORD" = "wallapass"; - #"SYMFONY__ENV__DATABASE_CHARSET" = "utf8mb4"; - }; - extraDockerOptions = [ "--network=wallabag-br" ]; - }; - - systemd.services.init-wallabag-docker-br = { - description = "Create the network bridge wallabag."; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - - serviceConfig.Type = "oneshot"; - script = let dockercli = "${config.virtualisation.docker.package}/bin/docker"; - in '' - # Put a true at the end to prevent getting non-zero return code, which will - # crash the whole service. - check=$(${dockercli} network ls | grep "wallabag-br" || true) - if [ -z "$check" ]; then - ${dockercli} network create wallabag-br - else - echo "wallabag-br already exists in docker" - fi - ''; - }; - networking.firewall.allowedTCPPorts = [ 800 ]; -} diff --git a/bowl/wallabag.nix b/bowl/wallabag.nix deleted file mode 100644 index 7039fd1a..00000000 --- a/bowl/wallabag.nix +++ /dev/null @@ -1,87 +0,0 @@ -{ pkgs, config, lib, ... }: - -{ - - services.wallabag = { - enable = true; - hostName = "read.mossnet.lan"; - package = pkgs.callPackage ./pkg-wallabag.nix {}; - conf = '' -# This file is a "template" of what your parameters.yml file should look like -parameters: - # Uncomment these settings or manually update your parameters.yml - # to use docker-compose - # - # database_driver: %env.database_driver% - # database_host: %env.database_host% - # database_port: %env.database_port% - # database_name: %env.database_name% - # database_user: %env.database_user% - # database_password: %env.database_password% - - database_driver: pdo_pgsql - database_host: localhost - database_port: ~ - database_name: wallabag - database_user: wallabag - database_password: wallabag - # For SQLite, database_path should be "%kernel.project_dir%/data/db/wallabag.sqlite" - database_path: ~ - database_table_prefix: wallabag_ - database_socket: null - # with PostgreSQL and SQLite, you must set "utf8" - database_charset: utf8 - - domain_name: http://read.mossnet.lan - server_name: "mossnet wallabag instance" - - mailer_transport: smtp - mailer_user: ~ - mailer_password: ~ - mailer_host: 127.0.0.1 - mailer_port: false - mailer_encryption: ~ - mailer_auth_mode: ~ - - locale: en - - # A secret key that's used to generate certain security-related tokens - secret: SAFGOECRIlfal89oe6u0(*^dsaaih961 - - # two factor stuff - twofactor_auth: true - twofactor_sender: no-reply@wallabag.org - - # fosuser stuff - fosuser_registration: true - fosuser_confirmation: true - - # how long the access token should live in seconds for the API - fos_oauth_server_access_token_lifetime: 3600 - # how long the refresh token should life in seconds for the API - fos_oauth_server_refresh_token_lifetime: 1209600 - - from_email: no-reply@wallabag.org - - rss_limit: 50 - - # RabbitMQ processing - rabbitmq_host: localhost - rabbitmq_port: 5672 - rabbitmq_user: guest - rabbitmq_password: guest - rabbitmq_prefetch_count: 10 - - # Redis processing - redis_scheme: tcp - redis_host: localhost - redis_port: 6379 - redis_path: null - redis_password: null - - # sentry logging - sentry_dsn: ~ -''; - }; - # networking.firewall.allowedTCPPorts = [ 8080 ]; -} diff --git a/bowl/wireguard.nix b/bowl/wireguard.nix deleted file mode 100644 index ebad01c3..00000000 --- a/bowl/wireguard.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ config, pkgs, ... }: - -{ - boot.extraModulePackages = with config.boot.kernelPackages; [ wireguard ]; - environment.systemPackages = [ pkgs.wireguard ]; - networking.wireguard.enable = true; - networking.wireguard.interfaces = { - wg0 = { - ips = [ "10.0.69.2/32" ]; - privateKeyFile = "/var/lib/wireguard/priv"; - - peers = [ - { # helix - server - publicKey = "{c1J4p63rD3IlszugMZiki7UBV3YmDdqa3DU4UejXzAI=}"; - allowedIPs = [ "10.0.69.1/24" ]; - endpoint = "sealight.xyz:60990"; - persistentKeepalive = 25; - } ]; - }; - }; -} diff --git a/bud/default.nix b/bud/default.nix new file mode 100644 index 00000000..c486636b --- /dev/null +++ b/bud/default.nix @@ -0,0 +1,10 @@ +{ pkgs, lib, budUtils, ... }: { + bud.cmds = with pkgs; { + get = { + writer = budUtils.writeBashWithPaths [ nixUnstable git coreutils ]; + synopsis = "get [DEST]"; + help = "Copy the desired template to DEST"; + script = ./get.bash; + }; + }; +} diff --git a/bud/get.bash b/bud/get.bash new file mode 100644 index 00000000..3b4d9a74 --- /dev/null +++ b/bud/get.bash @@ -0,0 +1 @@ +nix flake new -t "github:divnix/devos/core" "${2:-devos}" diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..0e6bdee2 --- /dev/null +++ b/default.nix @@ -0,0 +1,31 @@ +let + inherit (default.inputs.nixos) lib; + + default = (import ./lib/compat).defaultNix; + + ciSystems = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + ]; + + filterSystems = lib.filterAttrs + (system: _: lib.elem system ciSystems); + + recurseIntoAttrsRecursive = lib.mapAttrs (_: v: + if lib.isAttrs v + then recurseIntoAttrsRecursive (lib.recurseIntoAttrs v) + else v + ); + + systemOutputs = lib.filterAttrs + (name: set: lib.isAttrs set + && lib.any + (system: set ? ${system} && name != "legacyPackages") + ciSystems + ) + default.outputs; + + ciDrvs = lib.mapAttrs (_: system: filterSystems system) systemOutputs; +in +(recurseIntoAttrsRecursive ciDrvs) // { shell = import ./shell.nix; } diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..7585238e --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1 @@ +book diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md new file mode 100644 index 00000000..8574daea --- /dev/null +++ b/doc/CONTRIBUTING.md @@ -0,0 +1,18 @@ +# Pull Requests + +## TL;DR; +- **Target Branch**: `main` +- **Merge Policy**: [`bors`][bors] is alwyas right (→ `bors try`) +- **Docs**: every changeset is expected to contain doc updates +- **Commit Msg**: be a poet! Comprehensive and explanatory commit messages + should cover the motivation and use case in an easily understandable manner + even when read after a few months. +- **Test Driven Development**: please default to test driven development where possible. + +### Within the Devshell (`nix develop`) +- **Hooks**: please `git commit` within the devshell +- **Fail Early**: please run from within the devshell on your local machine: + - `nix flake check` + +[bors]: https://bors.tech + diff --git a/doc/SUMMARY.md b/doc/SUMMARY.md new file mode 100644 index 00000000..1d7bafe9 --- /dev/null +++ b/doc/SUMMARY.md @@ -0,0 +1,28 @@ +# Summary + +- [Introduction](../README.md) +- [Quick Start](./start/index.md) + - [ISO](./start/iso.md) + - [Bootstrapping](./start/bootstrapping.md) + - [From NixOS](./start/from-nixos.md) +- [Key Concepts](./concepts/index.md) + - [Hosts](./concepts/hosts.md) + - [Overrides](./concepts/overrides.md) + - [Profiles](./concepts/profiles.md) + - [Suites](./concepts/suites.md) + - [Users](./concepts/users.md) +- [Outputs](./outputs/index.md) + - [Modules](./outputs/modules.md) + - [Overlays](./outputs/overlays.md) + - [Packages](./outputs/pkgs.md) +- [Concerns]() + - [Secrets](./secrets.md) + - [Tests](./tests.md) +- [Helper Script โ€“ `bud`](./bud/index.md) + - [get](./bud/get.md) +- [Integrations](./integrations/index.md) + - [Cachix](./integrations/cachix.md) + - [Deploy RS](./integrations/deploy.md) + - [NvFetcher](./integrations/nvfetcher.md) + - [Hercules CI](./integrations/hercules.md) +- [Contributing](./CONTRIBUTING.md) diff --git a/doc/book.toml b/doc/book.toml new file mode 100644 index 00000000..373d26fd --- /dev/null +++ b/doc/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["Timothy DeHerrera"] +language = "en" +multilingual = false +src = "." +title = "devos docs" diff --git a/doc/bud/get.md b/doc/bud/get.md new file mode 100644 index 00000000..12263df0 --- /dev/null +++ b/doc/bud/get.md @@ -0,0 +1,10 @@ +# get +The `get` subcommand is useful for getting a bare copy of devos without the +git history. + +## Usage +```sh +bud get DEST-DIR +``` + +If DEST-DIR is ommitted, it defaults to _./devos_. diff --git a/doc/bud/index.md b/doc/bud/index.md new file mode 100644 index 00000000..7b985792 --- /dev/null +++ b/doc/bud/index.md @@ -0,0 +1,24 @@ +# [`bud`][bud] command +The template incudes a convenient script for managing your system called [`bud`][bud]. + +It is a portable and highly composable system control tool that work anywhere on your host +or in the flake's devshell. + +Although it comes with some predefined standard helpers, +it is very extensible and you are encouraged to write your own script snippets +to ease your workflows. An example is the bud module for a `get` command that +comes included with `devos`. + +While writing scripts you can convenientely access smart environment variables +that can tell the current architecture, user or host name, among others, regardless +wether you invoke `bud` within the devshell or as the system-wide installed `bud`. + +For details, please review the [bud repo][bud]. + +## Usage +```sh +bud help +``` + + +[bud]: https://github.com/divnix/bud diff --git a/doc/concepts/hosts.md b/doc/concepts/hosts.md new file mode 100644 index 00000000..1c3c3fa0 --- /dev/null +++ b/doc/concepts/hosts.md @@ -0,0 +1,62 @@ +# Hosts + +Nix flakes contain an output called `nixosConfigurations` declaring an +attribute set of valid NixOS systems. To simplify the management and creation +of these hosts, devos automatically imports every _.nix_ file inside this +directory to the mentioned attribute set, applying the projects defaults to +each. The only hard requirement is that the file contain a valid NixOS module. + +As an example, a file `hosts/system.nix` or `hosts/system/default.nix` will +be available via the flake output `nixosConfigurations.system`. You can have +as many hosts as you want and all of them will be automatically imported based +on their name. + +For each host, the configuration automatically sets the `networking.hostName` +attribute to the folder name or name of the file minus the _.nix_ extension. This +is for convenience, since `nixos-rebuild` automatically searches for a configuration +matching the current systems hostname if one is not specified explicitly. + +You can set channels, systems, and add extra modules to each host by editing the +`nixos.hosts` argument in flake.nix. This is the perfect place to import +host specific modules from external sources, such as the +[nixos-hardware][nixos-hardware] repository. + +It is recommended that the host modules only contain configuration information +specific to a particular piece of hardware. Anything reusable across machines +is best saved for [profile modules](./profiles.md). + +This is a good place to import sets of profiles, called [suites](./suites.md), +that you intend to use on your machine. + + +## Example + +flake.nix: +```nix +{ + nixos = { + imports = [ (devos.lib.importHosts ./hosts) ]; + hosts = { + librem = { + channelName = "latest"; + modules = [ nixos-hardware.nixosModules.purism-librem-13v3 ]; + }; + }; + }; +} +``` + +hosts/librem.nix: +```nix +{ suites, ... }: +{ + imports = suites.laptop; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; +} +``` + +[nixos-hardware]: https://github.com/NixOS/nixos-hardware diff --git a/doc/concepts/index.md b/doc/concepts/index.md new file mode 100644 index 00000000..618292cb --- /dev/null +++ b/doc/concepts/index.md @@ -0,0 +1,10 @@ +# Key Concepts + +Key concepts are derived from [digga][digga]. Please refer to its +[docs][digga-docs] for more details. + +This section is dedicated to helping you develop a more hands on +understanding of them them. + +[digga-docs]: https://digga.divnix.com +[digga]: https://github.com/divnix/digga diff --git a/doc/concepts/overrides.md b/doc/concepts/overrides.md new file mode 100644 index 00000000..610fde04 --- /dev/null +++ b/doc/concepts/overrides.md @@ -0,0 +1,42 @@ +# Overrides +Each NixOS host follows one channel. But many times it is useful to get packages +or modules from different channels. + +## Packages +You can make use of `overlays/overrides.nix` to override specific packages in the +default channel to be pulled from other channels. That file is simply an example +of how any overlay can get `channels` as their first argument. + +You can add overlays to any channel to override packages from other channels. + +Pulling the manix package from the `latest` channel: +```nix +channels: final: prev: { + __dontExport = true; + inherit (pkgs.latest) manix; +} +``` + +It is recommended to set the `__dontExport` property for override specific +overlays. `overlays/overrides.nix` is the best place to consolidate all package +overrides and the property is already set for you. + +## Modules + +You can also pull modules from other channels. All modules have access to the +`modulesPath` for each channel as `ModulesPath`. And you can use +`disabledModules` to remove modules from the current channel. + +To pull zsh module from the `latest` channel this code can be placed in any module, whether its your host file, a profile, or a module in ./modules etc: +```nix +{ latestModulesPath }: +{ + imports = [ "${latestModulesPath}/programs/zsh/zsh.nix" ]; + disabledModules = [ "programs/zsh/zsh.nix" ]; +} +``` + +> ##### _Note:_ +> Sometimes a modules name will change from one branch to another. + +[nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules diff --git a/doc/concepts/profiles.md b/doc/concepts/profiles.md new file mode 100644 index 00000000..a5eda3e2 --- /dev/null +++ b/doc/concepts/profiles.md @@ -0,0 +1,67 @@ +# Profiles + +Profiles are a convenient shorthand for the [_definition_][definition] of +[options][options] in contrast to their [_declaration_][declaration]. They're +built into the NixOS module system for a reason: to elegantly provide a clear +separation of concerns. + +## Creation +Profiles are created with the `rakeLeaves` function which recursively collects +`.nix` files from within a folder. The recursion stops at folders with a `default.nix` +in them. You end up with an attribute set with leaves(paths to profiles) or +nodes(attrsets leading to more nodes or leaves). + +A profile is used for quick modularization of [interelated bits](./profiles.md#subprofiles). + +> ##### _Notes:_ +> * For _declaring_ module options, there's the [modules](../outputs/modules.md) directory. +> * This directory takes inspiration from +> [upstream](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/profiles) +> . + +### Nested profiles +Profiles can be nested in attribute sets due to the recursive nature of `rakeLeaves`. +This can be useful to have a set of profiles created for a specific purpose. It is +sometimes useful to have a `common` profile that has high level concerns related +to all its sister profiles. + +### Example + +profiles/develop/common.nix: +```nix +{ + imports = [ ./zsh ]; + # some generic development concerns ... +} +``` + +profiles/develop/zsh.nix: +```nix +{ ... }: +{ + programs.zsh.enable = true; + # zsh specific options ... +} +``` + +The examples above will end up with a profiles set like this: +```nix +{ + develop = { + common = ./profiles/develop/common.nix; + zsh = ./profiles/develop/zsh.nix; + }; +} +``` + +## Conclusion +Profiles are the most important concept in DevOS. They allow us to keep our +Nix expressions self contained and modular. This way we can maximize reuse +across hosts while minimizing boilerplate. Remember, anything machine +specific belongs in your [host](hosts.md) files instead. + +[definition]: https://nixos.org/manual/nixos/stable/index.html#sec-option-definitions +[declaration]: https://nixos.org/manual/nixos/stable/index.html#sec-option-declarations +[options]: https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules +[spec]: https://github.com/divnix/devos/tree/core/lib/devos/mkProfileAttrs.nix +[config]: https://nixos.wiki/wiki/Module#structure diff --git a/doc/concepts/suites.md b/doc/concepts/suites.md new file mode 100644 index 00000000..42a3db82 --- /dev/null +++ b/doc/concepts/suites.md @@ -0,0 +1,25 @@ +# Suites +Suites provide a mechanism for users to easily combine and name collecitons of +profiles. + +`suites` are defined in the `importables` argument in either the `home` or `nixos` +namespace. They are a special case of an `importable` which get passed as a special +argument (one that can be use in an `imports` line) to your hosts. All lists defined +in `suites` are flattened and type-checked as paths. + +## Definition +```nix +rec { + workstation = [ profiles.develop profiles.graphical users.nixos ]; + mobileWS = workstation ++ [ profiles.laptop ]; +} +``` + +## Usage +`hosts/my-laptop.nix`: +```nix +{ suites, ... }: +{ + imports = suites.mobileWS; +} +``` diff --git a/doc/concepts/users.md b/doc/concepts/users.md new file mode 100644 index 00000000..12bf5622 --- /dev/null +++ b/doc/concepts/users.md @@ -0,0 +1,77 @@ +> ##### _Note:_ +> This section and its semantics need a conceptiual rework. +> Since recently [portable home configurations][portableuser] +> that are not bound to any specific host are a thing. + +# Users + +Users are a special case of [profiles](profiles.md) that define system +users and [home-manager][home-manager] configurations. For your convenience, +home manager is wired in by default so all you have to worry about is declaring +your users. For a fully fleshed out example, check out the developers personal +[branch](https://github.com/divnix/devos/tree/nrd/users/nrd/default.nix). + +## Basic Usage +`users/myuser/default.nix`: +```nix +{ ... }: +{ + users.users.myuser = { + isNormalUser = true; + }; + + home-manager.users.myuser = { + programs.mpv.enable = true; + }; +} + +``` + +## Home Manager +Home Manager support follows the same principles as regular nixos configurations, +it even gets its own namespace in your `flake.nix` as `home`. + +All modules defined in [user modules][modules-list] will be imported to +Home Manager. +User profiles can be collected in a similar fashion as system ones into a `suites` +argument that gets passed to your home-manager users. + +### Example +```nix +{ + home-manager.users.nixos = { suites, ... }: { + imports = suites.base; + }; +} +``` + + +## External Usage +You can easily use the defined home-manager configurations outside of NixOS +using the `homeConfigurations` flake output. The [flk](../flk/index.md) helper +script makes this even easier. + +This is great for keeping your environment consistent across Unix systems, +including OSX. + +### From within the projects devshell: +```sh +# builds the nixos user defined in the NixOS host +flk home NixOS nixos + +# build and activate +flk home NixOS nixos switch +``` + +### Manually from outside the project: +```sh +# build +nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage" + +# activate +./result/activate && unlink result +``` + +[home-manager]: https://nix-community.github.io/home-manager +[modules-list]: https://github.com/divnix/devos/tree/core/users/modules/module-list.nix +[portableuser]: https://digga.divnix.com/api-reference-home.html#homeusers diff --git a/doc/integrations/cachix.md b/doc/integrations/cachix.md new file mode 100644 index 00000000..b0254594 --- /dev/null +++ b/doc/integrations/cachix.md @@ -0,0 +1,17 @@ +# Cachix +The system will automatically pull a cachix.nix at the root if one exists. +This is usually created automatically by a `sudo cachix use`. If you're more +inclined to keep the root clean, you can drop any generated files in the +`cachix` directory into the `profiles/cachix` directory without further +modification. + +For example, to add your own cache, assuming the template lives in /etc/nixos, +by simply running `sudo cachix use yourcache`. Then, optionally, move +`cachix/yourcache.nix` to `profiles/cachix/yourcache.nix` + +These caches are only added to the system after a `nixos-rebuild switch`, so it +is recommended to call `cachix use nrdxp` before the initial deployment, as it +will save a lot of build time. + +In the future, users will be able to skip this step once the ability to define +the nix.conf within the flake is fully fleshed out upstream. diff --git a/doc/integrations/deploy.md b/doc/integrations/deploy.md new file mode 100644 index 00000000..29032108 --- /dev/null +++ b/doc/integrations/deploy.md @@ -0,0 +1,49 @@ +# deploy-rs +[Deploy-rs][d-rs] is a tool for managing NixOS remote machines. It was +chosen for devos after the author experienced some frustrations with the +stateful nature of nixops' db. It was also designed from scratch to support +flake based deployments, and so is an excellent tool for the job. + +By default, all the [hosts](../concepts/hosts.md) are also available as deploy-rs nodes, +configured with the hostname set to `networking.hostName`; overridable via +the command line. + +## Usage + +Just add your ssh key to the host: +```nix +{ ... }: +{ + users.users.${sshUser}.openssh.authorizedKeys.keyFiles = [ + ../secrets/path/to/key.pub + ]; +} +``` + +And the private key to your user: +```nix +{ ... }: +{ + home-manager.users.${sshUser}.programs.ssh = { + enable = true; + + matchBlocks = { + ${host} = { + host = hostName; + identityFile = ../secrets/path/to/key; + extraOptions = { AddKeysToAgent = "yes"; }; + }; + }; + } +} +``` + +And run the deployment: +```sh +deploy "flk#hostName" --hostname host.example.com +``` + +> ##### _Note:_ +> Your user will need **passwordless** sudo access + +[d-rs]: https://github.com/serokell/deploy-rs diff --git a/doc/integrations/hercules.md b/doc/integrations/hercules.md new file mode 100644 index 00000000..aa0185e4 --- /dev/null +++ b/doc/integrations/hercules.md @@ -0,0 +1,36 @@ +# Hercules CI +If you start adding your own packages and configurations, you'll probably have +at least a few binary artifacts. With hercules we can build every package in +our configuration automatically, on every commit. Additionally, we can have it +upload all our build artifacts to a binary cache like [cachix][cachix]. + +This will work whether your copy is a fork, or a bare template, as long as your +repo is hosted on GitHub. + +## Setup +Just head over to [hercules-ci.com](https://hercules-ci.com) to make an account. + +Then follow the docs to set up an [agent][agent], if you want to deploy to a +binary cache (and of course you do), be sure _not_ to skip the +[binary-caches.json][cache]. + +## Ready to Use +The repo is already set up with the proper _default.nix_ file, building all +declared packages, checks, profiles and shells. So you can see if something +breaks, and never build the same package twice! + +If you want to get fancy, you could even have hercules +[deploy your configuration](https://docs.hercules-ci.com/hercules-ci-effects/guide/deploy-a-nixos-machine/)! + +> ##### _Note:_ +> Hercules doesn't have access to anything encrypted in the +> [secrets folder](../../secrets), so none of your secrets will accidentally get +> pushed to a cache by mistake. +> +> You could pull all your secrets via your user, and then exclude it from +> [allUsers](https://github.com/nrdxp/devos/blob/nrd/suites/default.nix#L17) +> to keep checks passing. + +[agent]: https://docs.hercules-ci.com/hercules-ci/getting-started/#github +[cache]: https://docs.hercules-ci.com/hercules-ci/getting-started/deploy/nixos/#_3_configure_a_binary_cache +[cachix]: https://cachix.org diff --git a/doc/integrations/index.md b/doc/integrations/index.md new file mode 100644 index 00000000..5ea739ec --- /dev/null +++ b/doc/integrations/index.md @@ -0,0 +1,5 @@ +# Integrations +This section explores some of the optional tools included with devos to provide +a solution to common concerns such as ci and remote deployment. An effort is +made to choose tools that treat nix, and where possible flakes, as first class +citizens. diff --git a/doc/integrations/nvfetcher.md b/doc/integrations/nvfetcher.md new file mode 100644 index 00000000..4670657e --- /dev/null +++ b/doc/integrations/nvfetcher.md @@ -0,0 +1,43 @@ +# nvfetcher +[NvFetcher][nvf] is a workflow companion for updating nix sources. + +You can specify an origin source and an update configuration, and +nvfetcher can for example track updates to a specific branch and +automatically update your nix sources configuration on each run +to the tip of that branch. + +All package source declaration is done in [sources.toml][sources.toml]. + +From within the devshell of this repo, run `nvfetcher`, a wrapped +version of `nvfetcher` that knows where to find and place its files +and commit the results. + +## Usage + +Statically fetching (not tracking) a particular tag from a github repo: +```toml +[manix] +src.manual = "v0.6.3" +fetch.github = "mlvzk/manix" +``` + +Tracking the latest github _release_ from a github repo: +```toml +[manix] +src.github = "mlvzk/manix" # responsible for tracking +fetch.github = "mlvzk/manix" # responsible for fetching +``` + +Tracking the latest commit of a git repository and fetch from a git repo: +```toml +[manix] +src.git = "https://github.com/mlvzk/manix.git" # responsible for tracking +fetch.git = "https://github.com/mlvzk/manix.git" # responsible for fetching +``` + +> ##### _Note:_ +> Please refer to the [NvFetcher Readme][nvf-readme] for more options. + +[nvf]: https://github.com/berberman/nvfetcher +[nvf-readme]: https://github.com/berberman/nvfetcher#readme +[sources.toml]: https://github.com/divnix/devos/tree/core/pkgs/sources.toml diff --git a/doc/outputs/index.md b/doc/outputs/index.md new file mode 100644 index 00000000..36207188 --- /dev/null +++ b/doc/outputs/index.md @@ -0,0 +1,3 @@ +# Layout +Each of the following sections is a directory whose contents are output to the +outside world via the flake's outputs. Check each chapter for details. diff --git a/doc/outputs/modules.md b/doc/outputs/modules.md new file mode 100644 index 00000000..f698e9f6 --- /dev/null +++ b/doc/outputs/modules.md @@ -0,0 +1,79 @@ +# Modules +The modules directory is a replica of nixpkg's NixOS [modules][nixpkgs-modules] +, and follows the same semantics. This allows for trivial upstreaming into +nixpkgs proper once your module is sufficiently stable. + +All modules linked in _module-list.nix_ are automatically exported via +`nixosModules.`, and imported into all [hosts](../concepts/hosts.md). + + +> ##### _Note:_ +> This is reserved for declaring brand new module options. If you just want to +> declare a coherent configuration of already existing and related NixOS options +> , use [profiles](../concepts/profiles.md) instead. + +## Semantics +In case you've never written a module for nixpkgs before, here is a brief +outline of the process. + +### Declaration +modules/services/service-category/my-service.nix: +```nix +{ config, lib, ... }: +let + cfg = config.services.myService; +in +{ + options.services.myService = { + enable = lib.mkEnableOption "Description of my new service."; + + # additional options ... + }; + + config = lib.mkIf cfg.enable { + # implementation ... + }; +} +``` + +### Import +modules/module-list.nix: +```nix +[ + ./services/service-category/my-service.nix +] +``` + +## Usage + +### Internal +profiles/profile-category/my-profile.nix: +```nix +{ ... }: +{ + services.MyService.enable = true; +} +``` + +### External +flake.nix: +```nix +{ + # inputs omitted + + outputs = { self, devos, nixpkgs, ... }: { + nixosConfigurations.myConfig = nixpkgs.lib.nixosSystem { + system = "..."; + + modules = [ + devos.nixosModules.my-service + ({ ... }: { + services.MyService.enable = true; + }) + ]; + }; + }; +} +``` + +[nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules diff --git a/doc/outputs/overlays.md b/doc/outputs/overlays.md new file mode 100644 index 00000000..f463d1a7 --- /dev/null +++ b/doc/outputs/overlays.md @@ -0,0 +1,25 @@ +# Overlays +Writing overlays is a common occurence when using a NixOS system. Therefore, +we want to keep the process as simple and straightforward as possible. + +Any _.nix_ files declared in this directory will be assumed to be a valid +overlay, and will be automatically imported into all [hosts](../concepts/hosts.md), and +exported via `overlays./` _as well as_ +`packages..` (for valid systems), so all you have to do is +write it. + +## Example +overlays/kakoune.nix: +```nix +final: prev: { + kakoune = prev.kakoune.override { + configure.plugins = with final.kakounePlugins; [ + (kak-fzf.override { fzf = final.skim; }) + kak-auto-pairs + kak-buffers + kak-powerline + kak-vertical-selection + ]; + }; +} +``` diff --git a/doc/outputs/pkgs.md b/doc/outputs/pkgs.md new file mode 100644 index 00000000..4de93a8d --- /dev/null +++ b/doc/outputs/pkgs.md @@ -0,0 +1,109 @@ +# Packages +Similar to [modules](./modules.md), the pkgs directory mirrors the upstream +[nixpkgs/pkgs][pkgs], and for the same reason; if you ever want to upstream +your package, it's as simple as dropping it into the nixpkgs/pkgs directory. + +The only minor difference is that, instead of adding the `callPackage` call to +`all-packages.nix`, you just add it the the _default.nix_ in this directory, +which is defined as a simple overlay. + +All the packages are exported via `packages..`, for all +the supported systems listed in the package's `meta.platforms` attribute. + +And, as usual, every package in the overlay is also available to any NixOS +[host](../concepts/hosts.md). + +Another convenient difference is that it is possible to use +[nvfetcher](https://github.com/berberman/nvfetcher) to keep packages up to +date. +This is best understood by the simple example below. + +## Example +It is possible to specify sources separately to keep them up to date semi +automatically. +The basic rules are specified in pkgs/sources.toml: +```toml +# nvfetcher.toml +[libinih] +src.github = "benhoyt/inih" +fetch.github = "benhoyt/inih" +``` +After changes to this file as well as to update the packages specified in there run +nvfetcher (for more details see [nvfetcher](https://github.com/berberman/nvfetcher)). + +The pkgs overlay is managed in +pkgs/default.nix: +```nix +final: prev: { + # keep sources first, this makes sources available to the pkgs + sources = prev.callPackage (import ./_sources/generated.nix) { }; + + # then, call packages with `final.callPackage` + libinih = prev.callPackage ./development/libraries/libinih { }; +} +``` + +Lastly the example package is in +pkgs/development/libraries/libinih/default.nix: +```nix +{ stdenv, meson, ninja, lib, sources, ... }: +stdenv.mkDerivation { + pname = "libinih"; + + # version will resolve to the latest available on gitub + inherit (sources.libinih) version src; + + buildInputs = [ meson ninja ]; + + # ... +} +``` + + +## Migration from flake based approach +Previous to nvfetcher it was possible to manage sources via a pkgs/flake.nix, the main changes from there are that sources where in the attribute "srcs" (now "sources") and the contents of the sources where slightly different. +In order to switch to the new system, rewrite pkgs/flake.nix to a pkgs/sources.toml file using the documentation of nvfetcher, +add the line that calls the sources at the beginning of pkgs/default.nix, and +accomodate the small changes in the packages as can be seen from the example. + +The example package looked like: + +pkgs/flake.nix: +```nix +{ + description = "Package sources"; + + inputs = { + libinih.url = "github:benhoyt/inih/r53"; + libinih.flake = false; + }; +} +``` + +pkgs/default.nix: +```nix +final: prev: { + # then, call packages with `final.callPackage` + libinih = prev.callPackage ./development/libraries/libinih { }; +} +``` + +pkgs/development/libraries/libinih/default.nix: +```nix +{ stdenv, meson, ninja, lib, srcs, ... }: +let inherit (srcs) libinih; in +stdenv.mkDerivation { + pname = "libinih"; + + # version will resolve to 53, as specified in the flake.nix file + inherit (libinih) version; + + src = libinih; + + buildInputs = [ meson ninja ]; + + # ... +} +``` + +[pkgs]: https://github.com/NixOS/nixpkgs/tree/master/pkgs diff --git a/doc/secrets.md b/doc/secrets.md new file mode 100644 index 00000000..6afe2f6a --- /dev/null +++ b/doc/secrets.md @@ -0,0 +1,110 @@ +# Secrets +Secrets are managed using [git-crypt][git-crypt] and [agenix][agenix] +so you can keep your flake in a public repository like GitHub without +exposing your password or other sensitive data. + +By default, everything in the secrets folder is automatically encrypted. Just +be sure to run `git-crypt init` before putting anything in here. + +## Agenix +Currently, there is [no mechanism][secrets-issue] in nix itself to deploy secrets +within the nix store because it is world-readable. + +Most NixOS modules have the ability to set options to files in the system, outside +the nix store, that contain sensitive information. You can use [agenix][agenix] +to easily setup those secret files declaratively. + +[agenix][agenix] encrypts secrets and stores them as .age files in your repository. +Age files are encrypted with multiple ssh public keys, so any host or user with a +matching ssh private key can read the data. The [age module][age module] will add those +encrypted files to the nix store and decrypt them on activation to `/run/secrets`. + +### Setup +All hosts must have openssh enabled, this is done by default in the core profile. + +You need to populate your `secrets/secrets.nix` with the proper ssh public keys. +Be extra careful to make sure you only add public keys, you should never share a +private key!! + +secrets/secrets.nix: +```nix +let + system = ""; + user = ""; + allKeys = [ system user ]; +in +``` + +On most systems, you can get your systems ssh public key from `/etc/ssh/ssh_host_ed25519_key.pub`. If +this file doesn't exist you likely need to enable openssh and rebuild your system. + +Your users ssh public key is probably stored in `~/.ssh/id_ed25519.pub` or +`~/.ssh/id_rsa.pub`. If you haven't generated a ssh key yet, be sure do so: +```sh +ssh-keygen -t ed25519 +``` + +> ##### _Note:_ +> The underlying tool used by agenix, rage, doesn't work well with password protected +> ssh keys. So if you have lots of secrets you might have to type in your password many +> times. + + +### Secrets +You will need the `agenix` command to create secrets. DevOS conveniently provides that +in the devShell, so just run `nix develop` whenever you want to edit secrets. Make sure +to always run `agenix` while in the `secrets/` folder, so it can pick up your `secrets.nix`. + +To create secrets, simply add lines to your `secrets/secrets.nix`: +``` +let + ... + allKeys = [ system user ]; +in +{ + "secret.age".publicKeys = allKeys; +} +``` +That would tell agenix to create a `secret.age` file that is encrypted with the `system` +and `user` ssh public key. + +Then go into the `secrets` folder and run: +```sh +agenix -e secret.age +``` +This will create the `secret.age`, if it doesn't already exist, and allow you to edit it. + +If you ever change the `publicKeys` entry of any secret make sure to rekey the secrets: +```sh +agenix --rekey +``` + +### Usage +Once you have your secret file encrypted and ready to use, you can utilize the [age module][age module] +to ensure that your secrets end up in `/run/secrets`. + +In any profile that uses a NixOS module that requires a secret you can enable a particular secret like so: + +```nix +{ self, ... }: +{ + age.secrets.mysecret.file = "${self}/secrets/mysecret.age"; +} +``` + + +Then you can just pass the path `/run/secrets/mysecret` to the module. + +You can make use of the many options provided by the age module to customize where and how +secrets get decrypted. You can learn about them by looking at the +[age module][age module]. + + +> ##### _Note:_ +> You can take a look at the [agenix repository][agenix] for more information +> about the tool. + +[git-crypt]: https://github.com/AGWA/git-crypt +[agenix]: https://github.com/ryantm/agenix +[age module]: https://github.com/ryantm/agenix/blob/master/modules/age.nix +[secrets-issue]: https://github.com/NixOS/nix/issues/8 diff --git a/doc/start/bootstrapping.md b/doc/start/bootstrapping.md new file mode 100644 index 00000000..f4c5190e --- /dev/null +++ b/doc/start/bootstrapping.md @@ -0,0 +1,102 @@ +# Bootstrapping + +This will help you boostrap a bare host with the help of the +[bespoke iso](./iso.md) live installer. + +_Note: nothing prevents you from remotely executing the boostrapping +process. See below._ + +Once your target host has booted into the live iso, you need to partion +and format your disk according to the [official manual][manual]. + +## Mount partitions + +Then properly mount the formatted partitions at `/mnt`, so that you can +install your system to those new partitions. + +Mount `nixos` partition to `/mnt` and — for UEFI — `boot` +partition to `/mnt/boot`: + +```console +$ mount /dev/disk/by-label/nixos /mnt +$ mkdir -p /mnt/boot && mount /dev/disk/by-label/boot /mnt/boot # UEFI only +$ swapon /dev/disk/by-label/swap +``` + +Add some extra space to the store. In the iso, it's running on a tmpfs +off your RAM: +```console +$ mkdir -p /mnt/tmpstore/{work,store} +$ mount -t overlay overlay -olowerdir=/nix/store,upperdir=/mnt/tmpstore/store,workdir=/mnt/tmpstore/work /nix/store +``` + +## Install + +Install off of a copy of devos from the time the iso was built: + +```console +$ cd /iso/devos +$ nixos-install --flake .#NixOS +``` + +## Notes of interest + +### Remote access to the live installer + +The iso live installer comes preconfigured with a network configuration +which announces it's hostname via [MulticastDNS][mDNS] as `hostname.local`, +that is `bootstrap.local` in the [iso example](./iso). + +In the rare case that [MulticastDNS][mDNS] is not availabe or turned off +in your network, there is a static link-local IPv6 address configured to +`fe80::47`(mnemonic from the letter's position in the english alphabet: +`n=14 i=9 x=24; 47 = n+i+x`). + +Provided that you have added your public key to the authorized keys of the +`root` user _(hint: [`deploy-rs`](../integrations/deploy.md) needs passwordless +sudo access)_: + +```nix +{ ... }: +{ + users.users.root.openssh.authorizedKeys.keyFiles = [ + ../secrets/path/to/key.pub + ]; +} +``` + +You can then ssh into the live installer through one of the +following options: + +```console +ssh root@bootstrap.local + +ssh root@fe80::47%eno1 # where eno1 is your network interface on which you are linked to the target +``` + +_Note: the [static link-local IPv6 address][staticLLA] and [MulticastDNS][mDNS] is only +configured on the live installer. If you wish to enable [MulticastDNS][mDNS] +for your environment, you ought to configure that in a regular [profile](../concepts/profiles.md)._ + +### EUI-64 LLA & Host Identity + +The iso's IPv6 Link Local Address (LLA) is configured with a static 64-bit Extended +Unique Identifiers (EUI-64) that is derived from the host interface's Message +Authentication Code (MAC) address. + +After a little while (a few seconds), you can remotely discover this unique and host +specific address over [NDP][NDP] for example with: + +```console +ip -6 neigh show # also shows fe80::47 +``` + +***This LLA is stable for the host, unless you need to swap that particular network card.*** +Under this reservation, though, you may use this EUI-64 to wire up a specific +(cryptographic) host identity. + + +[manual]: https://nixos.org/manual/nixos/stable/index.html#sec-installation-partitioning +[mDNS]: https://en.wikipedia.org/wiki/Multicast_DNS +[NDP]: https://en.wikipedia.org/wiki/Neighbor_Discovery_Protocol +[staticLLA]: https://tools.ietf.org/html/rfc7404 diff --git a/doc/start/from-nixos.md b/doc/start/from-nixos.md new file mode 100644 index 00000000..0e1d48cb --- /dev/null +++ b/doc/start/from-nixos.md @@ -0,0 +1,54 @@ +# From NixOS + +## Generate Configuration +Assuming you're happy with your existing partition layout, you can generate a +basic NixOS configuration for your system using: +```sh +flk up +``` + +This will make a new file `hosts/up-$(hostname).nix`, which you can edit to +your liking. + +You must then add a host to `nixos.hosts` in flake.nix: +```nix +{ + nixos.hosts = { + modules = hosts/NixOS.nix; + }; +} +``` + +Make sure your `i18n.defaultLocale` and `time.timeZone` are set properly for +your region. Keep in mind that `networking.hostName` will be automatically +set to the name of your host; + +Now might be a good time to read the docs on [suites](../concepts/suites.md) and +[profiles](../concepts/profiles.md) and add or create any that you need. + +> ##### _Note:_ +> While the `up` sub-command is provided as a convenience to quickly set up and +> install a "fresh" NixOS system on current hardware, committing these files is +> discouraged. +> +> They are placed in the git staging area automatically because they would be +> invisible to the flake otherwise, but it is best to move what you need from +> them directly into a host module of your own making, and commit that instead. +# Installation + +Once you're ready to deploy `hosts/my-host.nix`: +```sh +flk my-host switch +``` + + +This calls `nixos-rebuild` with sudo to build and install your configuration. + +> ##### _Notes:_ +> - Instead of `switch`, you can pass `build`, `test`, `boot`, etc just as with +> `nixos-rebuild`. +> +> - It is convenient to have the template living at `/etc/nixos` so you can +> simply `sudo nixos-rebuild switch` from anywhere on the system, but it is +> not required. + diff --git a/doc/start/index.md b/doc/start/index.md new file mode 100644 index 00000000..f3f1127f --- /dev/null +++ b/doc/start/index.md @@ -0,0 +1,41 @@ +# Quick Start +The only dependency is nix, so make sure you have it [installed][install-nix]. + +## Get the Template +Here is a snippet that will get you the template without the git history: +```sh +nix-shell -p cachix --run "cachix use nrdxp" + +nix-shell https://github.com/divnix/devos/archive/core.tar.gz -A shell \ + --run "flk get core" + +cd flk + +nix-shell + +git init +git add . +git commit -m init +``` + +This will place you in a new folder named `flk` with git initialized, and a +nix-shell that provides all the dependencies, including the unstable nix +version required. + +In addition, the [binary cache](../integrations/cachix.md) is added for faster deployment. + +> ##### _Notes:_ +> - Flakes ignore files that have not been added to git, so be sure to stage new +> files before building the system. +> - You can choose to simply clone the repo with git if you want to follow +> upstream changes. +> - If the `nix-shell -p cachix --run "cachix use nrdxp"` line doesn't work +> you can try with sudo: `sudo nix-shell -p cachix --run "cachix use nrdxp"` + +## Next Steps: +- [Make installable ISO](./iso.md) +- [Bootstrap Host](./bootstrapping.md) +- [Already on NixOS](./from-nixos.md) + + +[install-nix]: https://nixos.org/manual/nix/stable/#sect-multi-user-installation diff --git a/doc/start/iso.md b/doc/start/iso.md new file mode 100644 index 00000000..76af1c6e --- /dev/null +++ b/doc/start/iso.md @@ -0,0 +1,22 @@ +# ISO + +Making and writing an installable iso for `hosts/bootstrap.nix` is as simple as: +```sh +bud build bootstrap bootstrapIso +sudo -E $(which bud) burn +``` + +This works for any host. + +## ISO image nix store & cache + +The iso image holds the store to the live environment and _also_ acts as a binary cache +to the installer. To considerably speed up things, the image already includes all flake +`inputs` as well as the `devshell` closures. + +While you _could_ provision any machine with a single stick, a custom-made iso for +the host you want to install DevOS to, maximises those local cache hits. + +For hosts that don't differ too much, a single usb stick might be ok, whereas when +there are bigger differences, a custom-made usb stick will be considerably faster. + diff --git a/doc/tests.md b/doc/tests.md new file mode 100644 index 00000000..1d7b65e2 --- /dev/null +++ b/doc/tests.md @@ -0,0 +1,33 @@ +# Testing + +Testing is always an important aspect of any software development project, and +NixOS offers some incredibly powerful tools to write tests for your +configuration, and, optionally, run them in +[CI](./integrations/hercules.md). + +## Unit Tests +Unit tests can be created from regular derivations, and they can do +almost anything you can imagine. By convention, it is best to test your +packages during their [check phase][check]. All packages and their tests will +be built during CI. + +## Integration Tests +All your profiles defined in suites will be tested in a NixOS VM. + +You can write integration tests for one or more NixOS VMs that can, +optionally, be networked together, and yes, it's as awesome as it sounds! + +Be sure to use the `mkTest` function from digga, `digga.lib.pkgs-lib.mkTest` +which wraps the official [testing-python][testing-python] function to ensure +that the system is setup exactly as it is for a bare DevOS system. There are +already great resources for learning how to use these tests effectively, +including the official [docs][test-doc], a fantastic [blog post][test-blog], +and the examples in [nixpkgs][nixos-tests]. + +[test-doc]: https://nixos.org/manual/nixos/stable/index.html#sec-nixos-tests +[test-blog]: https://www.haskellforall.com/2020/11/how-to-use-nixos-for-lightweight.html +[default]: https://github.com/divnix/devos/tree/core/tests/default.nix +[run-test]: https://github.com/NixOS/nixpkgs/blob/6571462647d7316aff8b8597ecdf5922547bf365/lib/debug.nix#L154-L166 +[nixos-tests]: https://github.com/NixOS/nixpkgs/tree/master/nixos/tests +[testing-python]: https://github.com/NixOS/nixpkgs/tree/master/nixos/lib/testing-python.nix +[check]: https://nixos.org/manual/nixpkgs/stable/#ssec-check-phase diff --git a/doc/theme/highlight.js b/doc/theme/highlight.js new file mode 100644 index 00000000..f4fd4fae --- /dev/null +++ b/doc/theme/highlight.js @@ -0,0 +1,6 @@ +/* + Highlight.js 10.1.2 (edd73d24) + License: BSD-3-Clause + Copyright (c) 2006-2020, Ivan Sagalaev +*/ +var hljs=function(){"use strict";function e(n){Object.freeze(n);var t="function"==typeof n;return Object.getOwnPropertyNames(n).forEach((function(r){!Object.hasOwnProperty.call(n,r)||null===n[r]||"object"!=typeof n[r]&&"function"!=typeof n[r]||t&&("caller"===r||"callee"===r||"arguments"===r)||Object.isFrozen(n[r])||e(n[r])})),n}class n{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data}ignoreMatch(){this.ignore=!0}}function t(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(e,...n){var t={};for(const n in e)t[n]=e[n];return n.forEach((function(e){for(const n in e)t[n]=e[n]})),t}function a(e){return e.nodeName.toLowerCase()}var i=Object.freeze({__proto__:null,escapeHTML:t,inherit:r,nodeStream:function(e){var n=[];return function e(t,r){for(var i=t.firstChild;i;i=i.nextSibling)3===i.nodeType?r+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:r,node:i}),r=e(i,r),a(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:r,node:i}));return r}(e,0),n},mergeStreams:function(e,n,r){var i=0,s="",o=[];function l(){return e.length&&n.length?e[0].offset!==n[0].offset?e[0].offset"}function u(e){s+=""}function d(e){("start"===e.event?c:u)(e.node)}for(;e.length||n.length;){var g=l();if(s+=t(r.substring(i,g[0].offset)),i=g[0].offset,g===e){o.reverse().forEach(u);do{d(g.splice(0,1)[0]),g=l()}while(g===e&&g.length&&g[0].offset===i);o.reverse().forEach(c)}else"start"===g[0].event?o.push(g[0].node):o.pop(),d(g.splice(0,1)[0])}return s+t(r.substr(i))}});const s="",o=e=>!!e.kind;class l{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=t(e)}openNode(e){if(!o(e))return;let n=e.kind;e.sublanguage||(n=`${this.classPrefix}${n}`),this.span(n)}closeNode(e){o(e)&&(this.buffer+=s)}value(){return this.buffer}span(e){this.buffer+=``}}class c{constructor(){this.rootNode={children:[]},this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n={kind:e,children:[]};this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(n=>this._walk(e,n)),e.closeNode(n)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every(e=>"string"==typeof e)?e.children=[e.children.join("")]:e.children.forEach(e=>{c._collapse(e)}))}}class u extends c{constructor(e){super(),this.options=e}addKeyword(e,n){""!==e&&(this.openNode(n),this.addText(e),this.closeNode())}addText(e){""!==e&&this.add(e)}addSublanguage(e,n){const t=e.root;t.kind=n,t.sublanguage=!0,this.add(t)}toHTML(){return new l(this,this.options).value()}finalize(){return!0}}function d(e){return e?"string"==typeof e?e:e.source:null}const g="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",h={begin:"\\\\[\\s\\S]",relevance:0},f={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[h]},p={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[h]},b={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},m=function(e,n,t={}){var a=r({className:"comment",begin:e,end:n,contains:[]},t);return a.contains.push(b),a.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),a},v=m("//","$"),x=m("/\\*","\\*/"),E=m("#","$");var _=Object.freeze({__proto__:null,IDENT_RE:"[a-zA-Z]\\w*",UNDERSCORE_IDENT_RE:"[a-zA-Z_]\\w*",NUMBER_RE:"\\b\\d+(\\.\\d+)?",C_NUMBER_RE:g,BINARY_NUMBER_RE:"\\b(0b[01]+)",RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=function(...e){return e.map(e=>d(e)).join("")}(n,/.*\b/,e.binary,/\b.*/)),r({className:"meta",begin:n,end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},BACKSLASH_ESCAPE:h,APOS_STRING_MODE:f,QUOTE_STRING_MODE:p,PHRASAL_WORDS_MODE:b,COMMENT:m,C_LINE_COMMENT_MODE:v,C_BLOCK_COMMENT_MODE:x,HASH_COMMENT_MODE:E,NUMBER_MODE:{className:"number",begin:"\\b\\d+(\\.\\d+)?",relevance:0},C_NUMBER_MODE:{className:"number",begin:g,relevance:0},BINARY_NUMBER_MODE:{className:"number",begin:"\\b(0b[01]+)",relevance:0},CSS_NUMBER_MODE:{className:"number",begin:"\\b\\d+(\\.\\d+)?(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[h,{begin:/\[/,end:/\]/,relevance:0,contains:[h]}]}]},TITLE_MODE:{className:"title",begin:"[a-zA-Z]\\w*",relevance:0},UNDERSCORE_TITLE_MODE:{className:"title",begin:"[a-zA-Z_]\\w*",relevance:0},METHOD_GUARD:{begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0},END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})}}),N="of and for in not or if then".split(" ");function w(e,n){return n?+n:function(e){return N.includes(e.toLowerCase())}(e)?0:1}const R=t,y=r,{nodeStream:O,mergeStreams:k}=i,M=Symbol("nomatch");return function(t){var a=[],i=Object.create(null),s=Object.create(null),o=[],l=!0,c=/(^(<[^>]+>|\t|)+|\n)/gm,g="Could not find the language '{}', did you forget to load/include a language module?";const h={disableAutodetect:!0,name:"Plain text",contains:[]};var f={noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:null,__emitter:u};function p(e){return f.noHighlightRe.test(e)}function b(e,n,t,r){var a={code:n,language:e};S("before:highlight",a);var i=a.result?a.result:m(a.language,a.code,t,r);return i.code=a.code,S("after:highlight",i),i}function m(e,t,a,s){var o=t;function c(e,n){var t=E.case_insensitive?n[0].toLowerCase():n[0];return Object.prototype.hasOwnProperty.call(e.keywords,t)&&e.keywords[t]}function u(){null!=y.subLanguage?function(){if(""!==A){var e=null;if("string"==typeof y.subLanguage){if(!i[y.subLanguage])return void k.addText(A);e=m(y.subLanguage,A,!0,O[y.subLanguage]),O[y.subLanguage]=e.top}else e=v(A,y.subLanguage.length?y.subLanguage:null);y.relevance>0&&(I+=e.relevance),k.addSublanguage(e.emitter,e.language)}}():function(){if(!y.keywords)return void k.addText(A);let e=0;y.keywordPatternRe.lastIndex=0;let n=y.keywordPatternRe.exec(A),t="";for(;n;){t+=A.substring(e,n.index);const r=c(y,n);if(r){const[e,a]=r;k.addText(t),t="",I+=a,k.addKeyword(n[0],e)}else t+=n[0];e=y.keywordPatternRe.lastIndex,n=y.keywordPatternRe.exec(A)}t+=A.substr(e),k.addText(t)}(),A=""}function h(e){return e.className&&k.openNode(e.className),y=Object.create(e,{parent:{value:y}})}function p(e){return 0===y.matcher.regexIndex?(A+=e[0],1):(L=!0,0)}var b={};function x(t,r){var i=r&&r[0];if(A+=t,null==i)return u(),0;if("begin"===b.type&&"end"===r.type&&b.index===r.index&&""===i){if(A+=o.slice(r.index,r.index+1),!l){const n=Error("0 width match regex");throw n.languageName=e,n.badRule=b.rule,n}return 1}if(b=r,"begin"===r.type)return function(e){var t=e[0],r=e.rule;const a=new n(r),i=[r.__beforeBegin,r["on:begin"]];for(const n of i)if(n&&(n(e,a),a.ignore))return p(t);return r&&r.endSameAsBegin&&(r.endRe=RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")),r.skip?A+=t:(r.excludeBegin&&(A+=t),u(),r.returnBegin||r.excludeBegin||(A=t)),h(r),r.returnBegin?0:t.length}(r);if("illegal"===r.type&&!a){const e=Error('Illegal lexeme "'+i+'" for mode "'+(y.className||"")+'"');throw e.mode=y,e}if("end"===r.type){var s=function(e){var t=e[0],r=o.substr(e.index),a=function e(t,r,a){let i=function(e,n){var t=e&&e.exec(n);return t&&0===t.index}(t.endRe,a);if(i){if(t["on:end"]){const e=new n(t);t["on:end"](r,e),e.ignore&&(i=!1)}if(i){for(;t.endsParent&&t.parent;)t=t.parent;return t}}if(t.endsWithParent)return e(t.parent,r,a)}(y,e,r);if(!a)return M;var i=y;i.skip?A+=t:(i.returnEnd||i.excludeEnd||(A+=t),u(),i.excludeEnd&&(A=t));do{y.className&&k.closeNode(),y.skip||y.subLanguage||(I+=y.relevance),y=y.parent}while(y!==a.parent);return a.starts&&(a.endSameAsBegin&&(a.starts.endRe=a.endRe),h(a.starts)),i.returnEnd?0:t.length}(r);if(s!==M)return s}if("illegal"===r.type&&""===i)return 1;if(B>1e5&&B>3*r.index)throw Error("potential infinite loop, way more iterations than matches");return A+=i,i.length}var E=T(e);if(!E)throw console.error(g.replace("{}",e)),Error('Unknown language: "'+e+'"');var _=function(e){function n(n,t){return RegExp(d(n),"m"+(e.case_insensitive?"i":"")+(t?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=function(e){return RegExp(e.toString()+"|").exec("").length-1}(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map(e=>e[1]);this.matcherRe=n(function(e,n="|"){for(var t=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,r=0,a="",i=0;i0&&(a+=n),a+="(";o.length>0;){var l=t.exec(o);if(null==l){a+=o;break}a+=o.substring(0,l.index),o=o.substring(l.index+l[0].length),"\\"===l[0][0]&&l[1]?a+="\\"+(+l[1]+s):(a+=l[0],"("===l[0]&&r++)}a+=")"}return a}(e),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const n=this.matcherRe.exec(e);if(!n)return null;const t=n.findIndex((e,n)=>n>0&&void 0!==e),r=this.matchIndexes[t];return n.splice(0,t),Object.assign(n,r)}}class a{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t;return this.rules.slice(e).forEach(([e,t])=>n.addRule(e,t)),n.compile(),this.multiRegexes[e]=n,n}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;const t=n.exec(e);return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&(this.regexIndex=0)),t}}function i(e,n){const t=e.input[e.index-1],r=e.input[e.index+e[0].length];"."!==t&&"."!==r||n.ignoreMatch()}if(e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return function t(s,o){const l=s;if(s.compiled)return l;s.compiled=!0,s.__beforeBegin=null,s.keywords=s.keywords||s.beginKeywords;let c=null;if("object"==typeof s.keywords&&(c=s.keywords.$pattern,delete s.keywords.$pattern),s.keywords&&(s.keywords=function(e,n){var t={};return"string"==typeof e?r("keyword",e):Object.keys(e).forEach((function(n){r(n,e[n])})),t;function r(e,r){n&&(r=r.toLowerCase()),r.split(" ").forEach((function(n){var r=n.split("|");t[r[0]]=[e,w(r[0],r[1])]}))}}(s.keywords,e.case_insensitive)),s.lexemes&&c)throw Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");return l.keywordPatternRe=n(s.lexemes||c||/\w+/,!0),o&&(s.beginKeywords&&(s.begin="\\b("+s.beginKeywords.split(" ").join("|")+")(?=\\b|\\s)",s.__beforeBegin=i),s.begin||(s.begin=/\B|\b/),l.beginRe=n(s.begin),s.endSameAsBegin&&(s.end=s.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(l.endRe=n(s.end)),l.terminator_end=d(s.end)||"",s.endsWithParent&&o.terminator_end&&(l.terminator_end+=(s.end?"|":"")+o.terminator_end)),s.illegal&&(l.illegalRe=n(s.illegal)),void 0===s.relevance&&(s.relevance=1),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cached_variants&&(e.cached_variants=e.variants.map((function(n){return r(e,{variants:null},n)}))),e.cached_variants?e.cached_variants:function e(n){return!!n&&(n.endsWithParent||e(n.starts))}(e)?r(e,{starts:e.starts?r(e.starts):null}):Object.isFrozen(e)?r(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){t(e,l)})),s.starts&&t(s.starts,o),l.matcher=function(e){const n=new a;return e.contains.forEach(e=>n.addRule(e.begin,{rule:e,type:"begin"})),e.terminator_end&&n.addRule(e.terminator_end,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(l),l}(e)}(E),N="",y=s||_,O={},k=new f.__emitter(f);!function(){for(var e=[],n=y;n!==E;n=n.parent)n.className&&e.unshift(n.className);e.forEach(e=>k.openNode(e))}();var A="",I=0,S=0,B=0,L=!1;try{for(y.matcher.considerAll();;){B++,L?L=!1:(y.matcher.lastIndex=S,y.matcher.considerAll());const e=y.matcher.exec(o);if(!e)break;const n=x(o.substring(S,e.index),e);S=e.index+n}return x(o.substr(S)),k.closeAllNodes(),k.finalize(),N=k.toHTML(),{relevance:I,value:N,language:e,illegal:!1,emitter:k,top:y}}catch(n){if(n.message&&n.message.includes("Illegal"))return{illegal:!0,illegalBy:{msg:n.message,context:o.slice(S-100,S+100),mode:n.mode},sofar:N,relevance:0,value:R(o),emitter:k};if(l)return{illegal:!1,relevance:0,value:R(o),emitter:k,language:e,top:y,errorRaised:n};throw n}}function v(e,n){n=n||f.languages||Object.keys(i);var t=function(e){const n={relevance:0,emitter:new f.__emitter(f),value:R(e),illegal:!1,top:h};return n.emitter.addText(e),n}(e),r=t;return n.filter(T).filter(I).forEach((function(n){var a=m(n,e,!1);a.language=n,a.relevance>r.relevance&&(r=a),a.relevance>t.relevance&&(r=t,t=a)})),r.language&&(t.second_best=r),t}function x(e){return f.tabReplace||f.useBR?e.replace(c,e=>"\n"===e?f.useBR?"
":e:f.tabReplace?e.replace(/\t/g,f.tabReplace):e):e}function E(e){let n=null;const t=function(e){var n=e.className+" ";n+=e.parentNode?e.parentNode.className:"";const t=f.languageDetectRe.exec(n);if(t){var r=T(t[1]);return r||(console.warn(g.replace("{}",t[1])),console.warn("Falling back to no-highlight mode for this block.",e)),r?t[1]:"no-highlight"}return n.split(/\s+/).find(e=>p(e)||T(e))}(e);if(p(t))return;S("before:highlightBlock",{block:e,language:t}),f.useBR?(n=document.createElement("div")).innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n"):n=e;const r=n.textContent,a=t?b(t,r,!0):v(r),i=O(n);if(i.length){const e=document.createElement("div");e.innerHTML=a.value,a.value=k(i,O(e),r)}a.value=x(a.value),S("after:highlightBlock",{block:e,result:a}),e.innerHTML=a.value,e.className=function(e,n,t){var r=n?s[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),e.includes(r)||a.push(r),a.join(" ").trim()}(e.className,t,a.language),e.result={language:a.language,re:a.relevance,relavance:a.relevance},a.second_best&&(e.second_best={language:a.second_best.language,re:a.second_best.relevance,relavance:a.second_best.relevance})}const N=()=>{if(!N.called){N.called=!0;var e=document.querySelectorAll("pre code");a.forEach.call(e,E)}};function T(e){return e=(e||"").toLowerCase(),i[e]||i[s[e]]}function A(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach(e=>{s[e]=n})}function I(e){var n=T(e);return n&&!n.disableAutodetect}function S(e,n){var t=e;o.forEach((function(e){e[t]&&e[t](n)}))}Object.assign(t,{highlight:b,highlightAuto:v,fixMarkup:x,highlightBlock:E,configure:function(e){f=y(f,e)},initHighlighting:N,initHighlightingOnLoad:function(){window.addEventListener("DOMContentLoaded",N,!1)},registerLanguage:function(e,n){var r=null;try{r=n(t)}catch(n){if(console.error("Language definition for '{}' could not be registered.".replace("{}",e)),!l)throw n;console.error(n),r=h}r.name||(r.name=e),i[e]=r,r.rawDefinition=n.bind(null,t),r.aliases&&A(r.aliases,{languageName:e})},listLanguages:function(){return Object.keys(i)},getLanguage:T,registerAliases:A,requireLanguage:function(e){var n=T(e);if(n)return n;throw Error("The '{}' language is required, but not loaded.".replace("{}",e))},autoDetection:I,inherit:y,addPlugin:function(e){o.push(e)}}),t.debugMode=function(){l=!1},t.safeMode=function(){l=!0},t.versionString="10.1.2";for(const n in _)"object"==typeof _[n]&&e(_[n]);return Object.assign(t,_),t}({})}();"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs);hljs.registerLanguage("xml",function(){"use strict";return function(e){var n={className:"symbol",begin:"&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;"},a={begin:"\\s",contains:[{className:"meta-keyword",begin:"#?[a-z_][a-z1-9_-]+",illegal:"\\n"}]},s=e.inherit(a,{begin:"\\(",end:"\\)"}),t=e.inherit(e.APOS_STRING_MODE,{className:"meta-string"}),i=e.inherit(e.QUOTE_STRING_MODE,{className:"meta-string"}),c={endsWithParent:!0,illegal:/`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,contains:[{className:"meta",begin:"",relevance:10,contains:[a,i,t,s,{begin:"\\[",end:"\\]",contains:[{className:"meta",begin:"",contains:[a,s,i,t]}]}]},e.COMMENT("\x3c!--","--\x3e",{relevance:10}),{begin:"<\\!\\[CDATA\\[",end:"\\]\\]>",relevance:10},n,{className:"meta",begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag",begin:")",end:">",keywords:{name:"style"},contains:[c],starts:{end:"",returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:")",end:">",keywords:{name:"script"},contains:[c],starts:{end:"<\/script>",returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:"",contains:[{className:"name",begin:/[^\/><\s]+/,relevance:0},c]}]}}}());hljs.registerLanguage("markdown",function(){"use strict";return function(n){const e={begin:"<",end:">",subLanguage:"xml",relevance:0},a={begin:"\\[.+?\\][\\(\\[].*?[\\)\\]]",returnBegin:!0,contains:[{className:"string",begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0,relevance:0},{className:"link",begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}],relevance:10},i={className:"strong",contains:[],variants:[{begin:/_{2}/,end:/_{2}/},{begin:/\*{2}/,end:/\*{2}/}]},s={className:"emphasis",contains:[],variants:[{begin:/\*(?!\*)/,end:/\*/},{begin:/_(?!_)/,end:/_/,relevance:0}]};i.contains.push(s),s.contains.push(i);var c=[e,a];return i.contains=i.contains.concat(c),s.contains=s.contains.concat(c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:c=c.concat(i,s)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:c}]}]},e,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i,s,{className:"quote",begin:"^>\\s+",contains:c,end:"$"},{className:"code",variants:[{begin:"(`{3,})(.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})(.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},a,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}}}());hljs.registerLanguage("perl",function(){"use strict";return function(e){var n={$pattern:/[\w.]+/,keyword:"getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmget sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when"},t={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:n},s={begin:"->{",end:"}"},r={variants:[{begin:/\$\d/},{begin:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{begin:/[\$%@][^\s\w{]/,relevance:0}]},i=[e.BACKSLASH_ESCAPE,t,r],a=[r,e.HASH_COMMENT_MODE,e.COMMENT("^\\=\\w","\\=cut",{endsWithParent:!0}),s,{className:"string",contains:i,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*\\<",end:"\\>",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:"{\\w+}",contains:[],relevance:0},{begin:"-?\\w+\\s*\\=\\>",contains:[],relevance:0}]},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",begin:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",relevance:10},{className:"regexp",begin:"(m|qr)?/",end:"/[a-z]*",contains:[e.BACKSLASH_ESCAPE],relevance:0}]},{className:"function",beginKeywords:"sub",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return t.contains=a,s.contains=a,{name:"Perl",aliases:["pl","pm"],keywords:n,contains:a}}}());hljs.registerLanguage("plaintext",function(){"use strict";return function(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}}());hljs.registerLanguage("ini",function(){"use strict";function e(e){return e?"string"==typeof e?e:e.source:null}function n(...n){return n.map(n=>e(n)).join("")}return function(a){var s={className:"number",relevance:0,variants:[{begin:/([\+\-]+)?[\d]+_[\d_]+/},{begin:a.NUMBER_RE}]},i=a.COMMENT();i.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];var t={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)}/}]},r={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[i,r,t,l,s,"self"],relevance:0},g="("+[/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/].map(n=>e(n)).join("|")+")";return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[i,{className:"section",begin:/\[+/,end:/\]+/},{begin:n(g,"(\\s*\\.\\s*",g,")*",n("(?=",/\s*=\s*[^#\s]/,")")),className:"attr",starts:{end:/$/,contains:[i,c,r,t,l,s]}}]}}}());hljs.registerLanguage("json",function(){"use strict";return function(n){var e={literal:"true false null"},i=[n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE],t=[n.QUOTE_STRING_MODE,n.C_NUMBER_MODE],a={end:",",endsWithParent:!0,excludeEnd:!0,contains:t,keywords:e},l={begin:"{",end:"}",contains:[{className:"attr",begin:/"/,end:/"/,contains:[n.BACKSLASH_ESCAPE],illegal:"\\n"},n.inherit(a,{begin:/:/})].concat(i),illegal:"\\S"},s={begin:"\\[",end:"\\]",contains:[n.inherit(a)],illegal:"\\S"};return t.push(l,s),i.forEach((function(n){t.push(n)})),{name:"JSON",contains:t,keywords:e,illegal:"\\S"}}}());hljs.registerLanguage("ruby",function(){"use strict";return function(e){var n="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",a={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},s={className:"doctag",begin:"@[A-Za-z]+"},i={begin:"#<",end:">"},r=[e.COMMENT("#","$",{contains:[s]}),e.COMMENT("^\\=begin","^\\=end",{contains:[s],relevance:10}),e.COMMENT("^__END__","\\n$")],c={className:"subst",begin:"#\\{",end:"}",keywords:a},t={className:"string",contains:[e.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:"%[qQwWx]?\\(",end:"\\)"},{begin:"%[qQwWx]?\\[",end:"\\]"},{begin:"%[qQwWx]?{",end:"}"},{begin:"%[qQwWx]?<",end:">"},{begin:"%[qQwWx]?/",end:"/"},{begin:"%[qQwWx]?%",end:"%"},{begin:"%[qQwWx]?-",end:"-"},{begin:"%[qQwWx]?\\|",end:"\\|"},{begin:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{begin:/<<[-~]?'?(\w+)(?:.|\n)*?\n\s*\1\b/,returnBegin:!0,contains:[{begin:/<<[-~]?'?/},e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,c]})]}]},b={className:"params",begin:"\\(",end:"\\)",endsParent:!0,keywords:a},d=[t,i,{className:"class",beginKeywords:"class module",end:"$|;",illegal:/=/,contains:[e.inherit(e.TITLE_MODE,{begin:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{begin:"<\\s*",contains:[{begin:"("+e.IDENT_RE+"::)?"+e.IDENT_RE}]}].concat(r)},{className:"function",beginKeywords:"def",end:"$|;",contains:[e.inherit(e.TITLE_MODE,{begin:n}),b].concat(r)},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(\\!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[t,{begin:n}],relevance:0},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{begin:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{className:"params",begin:/\|/,end:/\|/,keywords:a},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[i,{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:"%r{",end:"}[a-z]*"},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(r),relevance:0}].concat(r);c.contains=d,b.contains=d;var g=[{begin:/^\s*=>/,starts:{end:"$",contains:d}},{className:"meta",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+>|(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>)",starts:{end:"$",contains:d}}];return{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:a,illegal:/\/\*/,contains:r.concat(g).concat(d)}}}());hljs.registerLanguage("yaml",function(){"use strict";return function(e){var n="true false yes no null",a="[\\w#;/?:@&=+$,.~*\\'()[\\]]+",s={className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:"{{",end:"}}"},{begin:"%{",end:"}"}]}]},i=e.inherit(s,{variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),l={end:",",endsWithParent:!0,excludeEnd:!0,contains:[],keywords:n,relevance:0},t={begin:"{",end:"}",contains:[l],illegal:"\\n",relevance:0},g={begin:"\\[",end:"\\]",contains:[l],illegal:"\\n",relevance:0},b=[{className:"attr",variants:[{begin:"\\w[\\w :\\/.-]*:(?=[ \t]|$)"},{begin:'"\\w[\\w :\\/.-]*":(?=[ \t]|$)'},{begin:"'\\w[\\w :\\/.-]*':(?=[ \t]|$)"}]},{className:"meta",begin:"^---s*$",relevance:10},{className:"string",begin:"[\\|>]([0-9]?[+-])?[ ]*\\n( *)[\\S ]+\\n(\\2[\\S ]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+a},{className:"type",begin:"!<"+a+">"},{className:"type",begin:"!"+a},{className:"type",begin:"!!"+a},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"\\-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:e.C_NUMBER_RE+"\\b"},t,g,s],c=[...b];return c.pop(),c.push(i),l.contains=c,{name:"YAML",case_insensitive:!0,aliases:["yml","YAML"],contains:b}}}());hljs.registerLanguage("haskell",function(){"use strict";return function(e){var n={variants:[e.COMMENT("--","$"),e.COMMENT("{-","-}",{contains:["self"]})]},i={className:"meta",begin:"{-#",end:"#-}"},a={className:"meta",begin:"^#",end:"$"},s={className:"type",begin:"\\b[A-Z][\\w']*",relevance:0},l={begin:"\\(",end:"\\)",illegal:'"',contains:[i,a,{className:"type",begin:"\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?"},e.inherit(e.TITLE_MODE,{begin:"[_a-z][\\w']*"}),n]};return{name:"Haskell",aliases:["hs"],keywords:"let in if then else case of where do module import hiding qualified type data newtype deriving class instance as default infix infixl infixr foreign export ccall stdcall cplusplus jvm dotnet safe unsafe family forall mdo proc rec",contains:[{beginKeywords:"module",end:"where",keywords:"module where",contains:[l,n],illegal:"\\W\\.|;"},{begin:"\\bimport\\b",end:"$",keywords:"import qualified as hiding",contains:[l,n],illegal:"\\W\\.|;"},{className:"class",begin:"^(\\s*)?(class|instance)\\b",end:"where",keywords:"class family instance where",contains:[s,l,n]},{className:"class",begin:"\\b(data|(new)?type)\\b",end:"$",keywords:"data family type newtype deriving",contains:[i,s,l,{begin:"{",end:"}",contains:l.contains},n]},{beginKeywords:"default",end:"$",contains:[s,l,n]},{beginKeywords:"infix infixl infixr",end:"$",contains:[e.C_NUMBER_MODE,n]},{begin:"\\bforeign\\b",end:"$",keywords:"foreign import export ccall stdcall cplusplus jvm dotnet safe unsafe",contains:[s,e.QUOTE_STRING_MODE,n]},{className:"meta",begin:"#!\\/usr\\/bin\\/env runhaskell",end:"$"},i,a,e.QUOTE_STRING_MODE,e.C_NUMBER_MODE,s,e.inherit(e.TITLE_MODE,{begin:"^[_a-z][\\w']*"}),n,{begin:"->|<-"}]}}}());hljs.registerLanguage("nix",function(){"use strict";return function(e){var n={keyword:"rec with let in inherit assert if else then",literal:"true false or and null",built_in:"import abort baseNameOf dirOf isNull builtins map removeAttrs throw toString derivation"},i={className:"subst",begin:/\$\{/,end:/}/,keywords:n},t={className:"string",contains:[i],variants:[{begin:"''",end:"''"},{begin:'"',end:'"'}]},s=[e.NUMBER_MODE,e.HASH_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t,{begin:/[a-zA-Z0-9-_]+(\s*=)/,returnBegin:!0,relevance:0,contains:[{className:"attr",begin:/\S+/}]}];return i.contains=s,{name:"Nix",aliases:["nixos"],keywords:n,contains:s}}}());hljs.registerLanguage("bash",function(){"use strict";return function(e){const s={};Object.assign(s,{className:"variable",variants:[{begin:/\$[\w\d#@][\w\d_]*/},{begin:/\$\{/,end:/\}/,contains:[{begin:/:-/,contains:[s]}]}]});const t={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,t]};t.contains.push(n);const a={begin:/\$\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,s]},i=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b-?[a-z\._]+\b/,keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},contains:[i,e.SHEBANG(),c,a,e.HASH_COMMENT_MODE,n,{className:"",begin:/\\"/},{className:"string",begin:/'/,end:/'/},s]}}}());hljs.registerLanguage("shell",function(){"use strict";return function(s){return{name:"Shell Session",aliases:["console"],contains:[{className:"meta",begin:"^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]",starts:{end:"$",subLanguage:"bash"}}]}}}());hljs.registerLanguage("python",function(){"use strict";return function(e){var n={keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10",built_in:"Ellipsis NotImplemented",literal:"False None True"},a={className:"meta",begin:/^(>>>|\.\.\.) /},i={className:"subst",begin:/\{/,end:/\}/,keywords:n,illegal:/#/},s={begin:/\{\{/,relevance:0},r={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/(u|b)?r?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/(u|b)?r?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/(fr|rf|f)'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,i]},{begin:/(fr|rf|f)"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,i]},{begin:/(u|r|ur)'/,end:/'/,relevance:10},{begin:/(u|r|ur)"/,end:/"/,relevance:10},{begin:/(b|br)'/,end:/'/},{begin:/(b|br)"/,end:/"/},{begin:/(fr|rf|f)'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,i]},{begin:/(fr|rf|f)"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,i]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l={className:"number",relevance:0,variants:[{begin:e.BINARY_NUMBER_RE+"[lLjJ]?"},{begin:"\\b(0o[0-7]+)[lLjJ]?"},{begin:e.C_NUMBER_RE+"[lLjJ]?"}]},t={className:"params",variants:[{begin:/\(\s*\)/,skip:!0,className:null},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,contains:["self",a,l,r,e.HASH_COMMENT_MODE]}]};return i.contains=[r,l,a],{name:"Python",aliases:["py","gyp","ipython"],keywords:n,illegal:/(<\/|->|\?)|=>/,contains:[a,l,{beginKeywords:"if",relevance:0},r,e.HASH_COMMENT_MODE,{variants:[{className:"function",beginKeywords:"def"},{className:"class",beginKeywords:"class"}],end:/:/,illegal:/[${=;\n,]/,contains:[e.UNDERSCORE_TITLE_MODE,t,{begin:/->/,endsWithParent:!0,keywords:"None"}]},{className:"meta",begin:/^[\t ]*@/,end:/$/},{begin:/\b(print|exec)\(/}]}}}()); diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..b3efea01 --- /dev/null +++ b/flake.lock @@ -0,0 +1,430 @@ +{ + "nodes": { + "agenix": { + "inputs": { + "nixpkgs": [ + "latest" + ] + }, + "locked": { + "lastModified": 1620877075, + "narHash": "sha256-XvgTqtmQZHegu9UMDSR50gK5cHEM2gbnRH0qecmdN54=", + "owner": "ryantm", + "repo": "agenix", + "rev": "e543aa7d68f222e1e771165da9e9a64b5bf7b3e3", + "type": "github" + }, + "original": { + "owner": "ryantm", + "repo": "agenix", + "type": "github" + } + }, + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "bud": { + "inputs": { + "devshell": [ + "digga", + "devshell" + ], + "nixpkgs": [ + "nixos" + ] + }, + "locked": { + "lastModified": 1627855680, + "narHash": "sha256-snDOrUp8nth2Vs3GeEXr7Xji+HaHy25htZLNvid/U3I=", + "owner": "divnix", + "repo": "bud", + "rev": "612228a68d404d559405225427a5d8b3cef9d27c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "bud", + "type": "github" + } + }, + "darwin": { + "inputs": { + "nixpkgs": [ + "latest" + ] + }, + "locked": { + "lastModified": 1622060422, + "narHash": "sha256-hPVlvrAyf6zL7tTx0lpK+tMxEfZeMiIZ/A2xaJ41WOY=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "007d700e644ac588ad6668e6439950a5b6e2ff64", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "deploy": { + "inputs": { + "flake-compat": "flake-compat", + "naersk": "naersk", + "nixpkgs": [ + "digga", + "nixpkgs" + ], + "utils": [ + "digga", + "flake-utils" + ] + }, + "locked": { + "lastModified": 1628068208, + "narHash": "sha256-akJBkj6os4bjO1drhketJvXNC21yPuy4ufL2pyius4M=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "d72174307d5b88ec24cc2e69e875228fe3d642ed", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "devshell": { + "locked": { + "lastModified": 1625086391, + "narHash": "sha256-IpNPv1v8s4L3CoxhwcgZIitGpcrnNgnj09X7TA0QV3k=", + "owner": "numtide", + "repo": "devshell", + "rev": "4b5ac7cf7d9a1cc60b965bb51b59922f2210cbc7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "digga": { + "inputs": { + "blank": "blank", + "deploy": "deploy", + "devshell": "devshell", + "flake-utils": "flake-utils", + "flake-utils-plus": "flake-utils-plus", + "home-manager": [ + "home" + ], + "nixlib": [ + "nixos" + ], + "nixos-generators": "nixos-generators", + "nixpkgs": [ + "nixos" + ] + }, + "locked": { + "lastModified": 1628211944, + "narHash": "sha256-2q1dNUzitVd0JNRHYTubbyb8ks3fL9hPJOvQgofxELE=", + "owner": "divnix", + "repo": "digga", + "rev": "760bb9c29063258ba547145de0ab96acd7eba4c0", + "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-utils": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils-plus": { + "inputs": { + "flake-utils": [ + "digga", + "flake-utils" + ] + }, + "locked": { + "lastModified": 1627071952, + "narHash": "sha256-FhE0KOuI9Kl4eyGJXu4bh9fBP2hbxjnD1DlKHljCcYs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "51a82925db31073bc4822c9b538a0a3ebf1134b2", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "ref": "staging", + "repo": "flake-utils-plus", + "type": "github" + } + }, + "home": { + "inputs": { + "nixpkgs": [ + "nixos" + ] + }, + "locked": { + "lastModified": 1624228557, + "narHash": "sha256-wwOqe73BsrXfRv1PhyXQFNC8iTET50KvE/HitdkRgxs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "35a24648d155843a4d162de98c17b1afd5db51e4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-21.05", + "repo": "home-manager", + "type": "github" + } + }, + "latest": { + "locked": { + "lastModified": 1627942574, + "narHash": "sha256-guUcGRWvY2mfiVSet2x/zeHIyflm2wgglj0ldg0mMio=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c464dc811babfe316ed4ab7bbc12351122e69dd7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "digga", + "deploy", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1622810282, + "narHash": "sha256-4wmvM3/xfD0hCdNDIXVzRMfL4yB1J+DjH6Zte2xbAxk=", + "owner": "nmattia", + "repo": "naersk", + "rev": "e8061169e1495871b56be97c5c51d310fae01374", + "type": "github" + }, + "original": { + "owner": "nmattia", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, + "naersk_2": { + "inputs": { + "nixpkgs": [ + "latest" + ] + }, + "locked": { + "lastModified": 1623927034, + "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=", + "owner": "nmattia", + "repo": "naersk", + "rev": "e09c320446c5c2516d430803f7b19f5833781337", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixos": { + "locked": { + "lastModified": 1628203131, + "narHash": "sha256-jQgXeJ9NQQS0Eobb/qQOvS+RRULkqRikAeXkkFKOPDA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "178da37860823d35e801c7df2f73d7866d3d598a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": [ + "digga", + "nixlib" + ], + "nixpkgs": [ + "digga", + "blank" + ] + }, + "locked": { + "lastModified": 1624973746, + "narHash": "sha256-11JbJRduNwyf556gndGErR5/12ceyHOHBfEuha5Vws4=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "022ef440af8dc237ab1f59fa363cb1e25783ec3e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, + "nixos-hardware": { + "locked": { + "lastModified": 1625333638, + "narHash": "sha256-M6J9RN60XJyv6nUfDFCwnz5aVjhe8+GJnV8Q9VpdQQQ=", + "owner": "nixos", + "repo": "nixos-hardware", + "rev": "41775780a0b6b32b3d32dcc32bb9bc6df809062d", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nur": { + "locked": { + "lastModified": 1626378135, + "narHash": "sha256-koC6DBYmLCrgXA+AMHVaODf1uHYPmvcFygHfy3eg6vI=", + "owner": "nix-community", + "repo": "NUR", + "rev": "00c2ec8f0bbdf0cfb2135bde55fbae5d6b64aa6d", + "type": "github" + }, + "original": { + "id": "nur", + "type": "indirect" + } + }, + "nvfetcher": { + "inputs": { + "flake-compat": [ + "digga", + "deploy", + "flake-compat" + ], + "flake-utils": [ + "digga", + "flake-utils-plus", + "flake-utils" + ], + "nixpkgs": [ + "latest" + ] + }, + "locked": { + "lastModified": 1627523399, + "narHash": "sha256-j9CgnUQpWcb8OB4LRzPW8BdxvmoROJptgptDlPA8Heo=", + "owner": "berberman", + "repo": "nvfetcher", + "rev": "fb8f2cc770ad3dd3e29d7ba3004692d4d53fba9b", + "type": "github" + }, + "original": { + "owner": "berberman", + "repo": "nvfetcher", + "type": "github" + } + }, + "root": { + "inputs": { + "agenix": "agenix", + "blank": [ + "digga", + "blank" + ], + "bud": "bud", + "darwin": "darwin", + "deploy": [ + "digga", + "deploy" + ], + "digga": "digga", + "flake-utils": [ + "digga", + "flake-utils" + ], + "flake-utils-plus": [ + "digga", + "flake-utils-plus" + ], + "home": "home", + "latest": "latest", + "naersk": "naersk_2", + "nixlib": [ + "digga", + "nixlib" + ], + "nixos": "nixos", + "nixos-hardware": "nixos-hardware", + "nixpkgs": [ + "nixos" + ], + "nur": "nur", + "nvfetcher": "nvfetcher" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..bba4f434 --- /dev/null +++ b/flake.nix @@ -0,0 +1,158 @@ +{ + description = "A highly structured configuration database."; + + nixConfig.extra-experimental-features = "nix-command flakes ca-references"; + nixConfig.extra-substituters = "https://nrdxp.cachix.org https://nix-community.cachix.org"; + nixConfig.extra-trusted-public-keys = "nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="; + + inputs = + { + nixos.url = "github:nixos/nixpkgs/release-21.05"; + latest.url = "github:nixos/nixpkgs/nixos-unstable"; + + digga.url = "github:divnix/digga"; + digga.inputs.nixpkgs.follows = "nixos"; + digga.inputs.nixlib.follows = "nixos"; + digga.inputs.home-manager.follows = "home"; + + bud.url = "github:divnix/bud"; + bud.inputs.nixpkgs.follows = "nixos"; + bud.inputs.devshell.follows = "digga/devshell"; + + home.url = "github:nix-community/home-manager/release-21.05"; + home.inputs.nixpkgs.follows = "nixos"; + + darwin.url = "github:LnL7/nix-darwin"; + darwin.inputs.nixpkgs.follows = "latest"; + + deploy.follows = "digga/deploy"; + + agenix.url = "github:ryantm/agenix"; + agenix.inputs.nixpkgs.follows = "latest"; + + nvfetcher.url = "github:berberman/nvfetcher"; + nvfetcher.inputs.nixpkgs.follows = "latest"; + nvfetcher.inputs.flake-compat.follows = "digga/deploy/flake-compat"; + nvfetcher.inputs.flake-utils.follows = "digga/flake-utils-plus/flake-utils"; + + naersk.url = "github:nmattia/naersk"; + naersk.inputs.nixpkgs.follows = "latest"; + + nixos-hardware.url = "github:nixos/nixos-hardware"; + + # start ANTI CORRUPTION LAYER + # remove after https://github.com/NixOS/nix/pull/4641 + nixpkgs.follows = "nixos"; + nixlib.follows = "digga/nixlib"; + blank.follows = "digga/blank"; + flake-utils-plus.follows = "digga/flake-utils-plus"; + flake-utils.follows = "digga/flake-utils"; + # end ANTI CORRUPTION LAYER + }; + + outputs = + { self + , digga + , bud + , nixos + , home + , nixos-hardware + , nur + , agenix + , nvfetcher + , deploy + , ... + } @ inputs: + digga.lib.mkFlake + { + inherit self inputs; + + channelsConfig = { allowUnfree = true; }; + + channels = { + nixos = { + imports = [ (digga.lib.importOverlays ./overlays) ]; + overlays = [ + digga.overlays.patchedNix + nur.overlay + agenix.overlay + nvfetcher.overlay + deploy.overlay + ./pkgs/default.nix + ]; + }; + latest = { }; + }; + + lib = import ./lib { lib = digga.lib // nixos.lib; }; + + sharedOverlays = [ + (final: prev: { + __dontExport = true; + lib = prev.lib.extend (lfinal: lprev: { + our = self.lib; + }); + }) + ]; + + nixos = { + hostDefaults = { + system = "x86_64-linux"; + channelName = "nixos"; + imports = [ (digga.lib.importModules ./modules) ]; + externalModules = [ + { lib.our = self.lib; } + digga.nixosModules.bootstrapIso + digga.nixosModules.nixConfig + home.nixosModules.home-manager + agenix.nixosModules.age + bud.nixosModules.bud + ]; + }; + + imports = [ (digga.lib.importHosts ./hosts) ]; + hosts = { + /* set host specific properties here */ + NixOS = { }; + }; + importables = rec { + profiles = digga.lib.rakeLeaves ./profiles // { + users = digga.lib.rakeLeaves ./users; + }; + suites = with profiles; rec { + base = [ core users.nixos users.root ]; + }; + }; + }; + + home = { + imports = [ (digga.lib.importModules ./users/modules) ]; + externalModules = [ ]; + importables = rec { + profiles = digga.lib.rakeLeaves ./users/profiles; + suites = with profiles; rec { + base = [ direnv git ]; + }; + }; + users = { + nixos = { suites, ... }: { imports = suites.base; }; + }; # digga.lib.importers.rakeLeaves ./users/hm; + }; + + devshell = ./shell; + + homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; + + deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; + + defaultTemplate = self.templates.bud; + templates.bud.path = ./.; + templates.bud.description = "bud template"; + + } + // + { + budModules = { devos = import ./bud; }; + } + ; +} diff --git a/hosts/NixOS.nix b/hosts/NixOS.nix new file mode 100644 index 00000000..3b084119 --- /dev/null +++ b/hosts/NixOS.nix @@ -0,0 +1,12 @@ +{ suites, ... }: +{ + ### root password is empty by default ### + imports = suites.base; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.networkmanager.enable = true; + + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; +} diff --git a/hosts/bootstrap.nix b/hosts/bootstrap.nix new file mode 100644 index 00000000..d491855d --- /dev/null +++ b/hosts/bootstrap.nix @@ -0,0 +1,18 @@ +{ profiles, ... }: +{ + # build with: `bud build bootstrap bootstrapIso` + # reachable on the local link via ssh root@fe80::47%eno1 + # where 'eno1' is replaced by your own machine's network + # interface that has the local link to the target machine + imports = [ + # profiles.networking + profiles.core + profiles.users.root # make sure to configure ssh keys + profiles.users.nixos + ]; + + boot.loader.systemd-boot.enable = true; + + # will be overridden by the bootstrapIso instrumentation + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; +} diff --git a/lib/compat/default.nix b/lib/compat/default.nix new file mode 100644 index 00000000..9d0c2837 --- /dev/null +++ b/lib/compat/default.nix @@ -0,0 +1,14 @@ +let + rev = "e7e5d481a0e15dcd459396e55327749989e04ce0"; + flake = (import + ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz"; + sha256 = "0zd3x46fswh5n6faq4x2kkpy6p3c6j593xbdlbsl40ppkclwc80x"; + } + ) + { + src = ../../.; + }); +in +flake diff --git a/lib/compat/nixos/default.nix b/lib/compat/nixos/default.nix new file mode 100644 index 00000000..e4e0e68a --- /dev/null +++ b/lib/compat/nixos/default.nix @@ -0,0 +1,10 @@ +{ ... }: +let + inherit (default.inputs.nixos) lib; + + host = configs.${hostname} or configs.NixOS; + configs = default.nixosConfigurations; + default = (import ../.).defaultNix; + hostname = lib.fileContents /etc/hostname; +in +host diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 00000000..2356e1f0 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,2 @@ +{ lib }: +lib.makeExtensible (self: { }) diff --git a/machines/bowl.nix b/machines/bowl.nix deleted file mode 100644 index 70deb4fd..00000000 --- a/machines/bowl.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ config, pkgs, ... }: -{ -imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ./taskd.nix - ./nextcloud.nix - ./networking.nix -# ./wireguard.nix -# ./shiori.nix - ./shaarli.nix -# ./shaarli-tokudan.nix -# ./mod-wallabag.nix -# ./pkg-wallabag.nix - ./navidrome.nix - ./pkg-navidrome.nix -# ./wallabag.nix - ./headphones.nix - ./dns.nix - ./backup.nix - ./monitoring.nix - ]; - - boot.loader.grub.devices = [ "/dev/sda" ]; - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.enableCryptodisk = true; - boot.loader.supportsInitrdSecrets = true; - - boot.initrd.kernelModules = [ "dm-snapshot" ]; - boot.initrd.availableKernelModules = ["virtio-pci"]; - boot.initrd.network = { - enable = true; - ssh = { - enable = true; - port = 2222; - authorizedKeys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKN8/SH55DBiwVoSnTU8k2Pen+wmovL9QaMyehxGEsJJv/8fzwsswGalD4C/4O51LOvdu4UKkZW5hG02uVSK+58p3UV3pOPyoqsu/aDeIsWsqmTeTzUrBIWOlNzcDKnohLz2oGC5YO+wyTJ9Iteq6aGJDjErsW7sG3h5lXCs551EmJNNGhtBQaaoytMNnWqSdlVjDNCijurH7WUpp40U/RjEp532l4rX6eIIj3jBKEFbhZkFSSjqbj4xM4SyFt+Jmigb1RMjsQjmpfY1vDtM84RcYfpTUte/T5w2dkD5H6kccmWnwKSJpm9wXfx4E7lR9APdUGnau2U1+XxiD3ytGl anish@box -"]; - hostKeys = [ "/host_ecdsa_key" ]; - }; - }; - - boot.initrd.luks.devices = { - "enc-pv" = { - name = "enc-pv"; - preLVM = true; - device = "/dev/disk/by-uuid/425cc402-9221-474f-aaf1-10ac7cd4c93c"; - allowDiscards = true; - }; - }; - - boot.initrd.secrets = { - "/host_ecdsa_key" = "/host_ecdsa_key"; - }; - - - boot.cleanTmpDir = true; - boot.kernelModules = [ "dm-snapshot" ]; - - users.users.anish = { - isNormalUser = true; - extraGroups = [ "wheel" ]; - hashedPassword = "MO0Pbd2O4eIlA"; - openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKN8/SH55DBiwVoSnTU8k2Pen+wmovL9QaMyehxGEsJJv/8fzwsswGalD4C/4O51LOvdu4UKkZW5hG02uVSK+58p3UV3pOPyoqsu/aDeIsWsqmTeTzUrBIWOlNzcDKnohLz2oGC5YO+wyTJ9Iteq6aGJDjErsW7sG3h5lXCs551EmJNNGhtBQaaoytMNnWqSdlVjDNCijurH7WUpp40U/RjEp532l4rX6eIIj3jBKEFbhZkFSSjqbj4xM4SyFt+Jmigb1RMjsQjmpfY1vDtM84RcYfpTUte/T5w2dkD5H6kccmWnwKSJpm9wXfx4E7lR9APdUGnau2U1+XxiD3ytGl anish@box ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM8kTdMGGmr6mv/zv+K9qVjhzqwivyyN5IV04R7/kcWKw1c6ZEzzqqmsnJ/hci6IIxZ/VEUzMhYz0iBCL0wJHHMxYoNCgISWePtDlVJdyrzm9OWjJNcRStZBW3XcY9dELJsCVcQ4LAVYE4vA+MdmbwM2FZgJhAH6qUzujpfNrj/YIVG7MTN6tbUd63uZF57F43c8WUjgRJx2o7Wl9bSe6v3PZ4fAgEO+wQPso+W+pEXLZ3hBNrHdybwdoGvG9tHlBDbLid11BxtpzmwR9CydDfpbyOXB2+tJkkNXhsHB22mN/2+vGWYhDKYPTFqbDW7McDfQChySyYDdZWmg5WHIGz anish@curve" ]; - }; - - users.users.root.initialHashedPassword = ""; - services.openssh.permitRootLogin = "prohibit-password"; - networking.hostName = "bowl"; - services.openssh.enable = true; - services.logind.lidSwitch = "ignore"; - system.stateVersion = "20.09"; - time.timeZone = "Australia/Brisbane"; -} diff --git a/machines/box.nix b/machines/box.nix deleted file mode 100644 index 51d33dfe..00000000 --- a/machines/box.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, pkgs, ... }: - -{ - - imports = [ - # install software - ./common.nix - ]; - - services.xserver = { - enable = true; - displayManager.gdm.enable = true; - desktopManager.gnome3.enable = true; - }; - - # task whisperer broken - nixpkgs.config.allowBroken = true; - - # virtual box - virtualisation.virtualbox.host.enable = true; - - # ErgoDox Firmware (doesn't compile) - # environment.systemPackages = with pkgs; [ - # qmk_firmware - # ]; -} - diff --git a/machines/helix.nix b/machines/helix.nix deleted file mode 100644 index 88fe3172..00000000 --- a/machines/helix.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, pkgs, ... }: -{ - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ./wireguard.nix - ./matrix.nix - ]; - - # Use the GRUB 2 boot loader. - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.device = "/dev/vda"; # or "nodev" for efi only - - networking.hostName = "helix"; # Define your hostname. - - networking.useDHCP = false; - networking.interfaces.ens3.useDHCP = true; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - #services.openssh.passwordAuthentication = false; - services.openssh.permitRootLogin = "no"; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # Define a user account. Don't forget to set a password with โ€˜passwdโ€™. - users.users.anish = { - isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable โ€˜sudoโ€™ for the user - openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM8kTdMGGmr6mv/zv+K9qVjhzqwivyyN5IV04R7/kcWKw1c6ZEzzqqmsnJ/hci6IIxZ/VEUzMhYz0iBCL0wJHHMxYoNCgISWePtDlVJdyrzm9OWjJNcRStZBW3XcY9dELJsCVcQ4LAVYE4vA+MdmbwM2FZgJhAH6qUzujpfNrj/YIVG7MTN6tbUd63uZF57F43c8WUjgRJx2o7Wl9bSe6v3PZ4fAgEO+wQPso+W+pEXLZ3hBNrHdybwdoGvG9tHlBDbLid11BxtpzmwR9CydDfpbyOXB2+tJkkNXhsHB22mN/2+vGWYhDKYPTFqbDW7McDfQChySyYDdZWmg5WHIGz anish@curve" - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCeWQsf9rbE+KBrWLkLkg1PMKx0jPfDP8xyv+XtddIQzAskRTN+JSSQp1GpoRgfQij7bx6f6DfjkwSQK5NWDQNQ+klGhcdEwEdptWUzpRAvKHMImjyIwFHmRKKEgcfH8+DSHVM93nRSQKrLezX4PzPkHF9f3TLxFdGeQDeY0J2oP2Oa97hRtuTJZW9BwUojyvDYUbg7F3fxf+pdFCvIAFaayiLkhOYdTXnjLt1Ks6NOhSzM78ZibHv4pFYI9r6dhflkFP/SzyLeSSm1aVAtxqE7vF5HnnORAg0byDsiOv/9RXxiDx7gkAAw3xENDSpp9TRj54M7iz1OSsRMhmD6orHjZFIRejlE4DIn+PBPm3PH+U5ILKTogE6n5MfPT28V0QdtHuqq3b5tSWiDcFpnjxbIUmEIo5hLzMR0tXZoNLQhBCSNfxjE8CYzpk7mHbvhSs2GPfG+NI1vvldbw2EF8beJFQHNYTqJw8y7p8RXpCwZqqpSitJX6v9DiYdLVG1hWvE= nix-on-droid@localhost" - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKN8/SH55DBiwVoSnTU8k2Pen+wmovL9QaMyehxGEsJJv/8fzwsswGalD4C/4O51LOvdu4UKkZW5hG02uVSK+58p3UV3pOPyoqsu/aDeIsWsqmTeTzUrBIWOlNzcDKnohLz2oGC5YO+wyTJ9Iteq6aGJDjErsW7sG3h5lXCs551EmJNNGhtBQaaoytMNnWqSdlVjDNCijurH7WUpp40U/RjEp532l4rX6eIIj3jBKEFbhZkFSSjqbj4xM4SyFt+Jmigb1RMjsQjmpfY1vDtM84RcYfpTUte/T5w2dkD5H6kccmWnwKSJpm9wXfx4E7lR9APdUGnau2U1+XxiD3ytGl anish@box" ]; - }; - - # This value determines the NixOS release with which your system is to be - # compatible, in order to avoid breaking some software such as database - # servers. You should change this only after NixOS release notes say you - # should. - system.stateVersion = "19.09"; # Did you read the comment? - -} - diff --git a/modules/backup.nix b/modules/backup.nix deleted file mode 100644 index 8fa6f01c..00000000 --- a/modules/backup.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - # Assumes the remote borg backup server has already been initialized - # borg init --encryption-key=repokey-blake2 -rsh 'ssh -i /run/keys/id_ed25519_borgbase' 20779@hk-s020.rsync.net: - services.borgbackup.jobs = { - backupTaskwarriorRsync = { - paths = [ "/var/lib/taskserver" ]; - doInit = true; - repo = "20779@hk-s020.rsync.net:taskwarrior" ; - encryption = { - mode = "repokey-blake2"; - passCommand = "cat /run/keys/rsync"; - }; - environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; - compression = "auto,lzma"; - startAt = "weekly"; - extraArgs = "--remote-path=borg1"; - }; - }; - services.borgbackup.jobs = { - backupShaarliRsync = { - paths = [ "/var/www/shaarli-config/data/datastore.php" "/var/www/shaarli-config/config" "/var/www/shaarli-config/.json.config" ]; - doInit = true; - repo = "20779@hk-s020.rsync.net:shaarli" ; - encryption = { - mode = "repokey-blake2"; - passCommand = "cat /run/keys/rsync"; - }; - environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; - compression = "auto,lzma"; - startAt = "weekly"; - extraArgs = "--remote-path=borg1"; - }; - }; -} diff --git a/modules/common.nix b/modules/common.nix deleted file mode 100644 index 0079ccc2..00000000 --- a/modules/common.nix +++ /dev/null @@ -1,114 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ./nvim.nix -# ./unstable.nix - ]; - - - environment.systemPackages = with pkgs; [ - htop - iftop - wget - curl - exa - bat - fd - ag - tcpdump - whois - mtr - file - lsof - atool - inotify-tools - strace - zip - unzip - rsync - tmux - pwgen - glow - gitAndTools.gitFull - #neovim defined in ./nvim.nix - wofi - firefox - fractal - pinentry_gnome - pass - gcc - less - mpv - zathura - #qmk_firmware - python3 - gdb - vcv-rack - #xdotool - #neofetch - #calibre - #openvpn - gimp - xxd - tilix - kitty - taskwarrior - gnupg - openjdk - glslviewer - filezilla - signal-desktop - wire-desktop - tdesktop - feedreader - newsflash - syncthing - dijo - #kdeconnect - #ssb-patchwork - gnome3.gnome-tweaks - gnome3.pomodoro - gnomeExtensions.gsconnect - gnomeExtensions.taskwhisperer - #gnome3.networkmanager-openvpn - #python3Packages.youtube-dl - appimage-run - home-manager - libreoffice - fontconfig - hugo - #processing - #nextcloud-client - zsh-powerlevel10k - powerline-fonts - supercollider - haskellPackages.tidal - # vim-zettel - pandoc - ]; - - programs.bash.enableCompletion = true; - - # needed for vcv-rack - nixpkgs.config.allowUnfree = true; - - system.copySystemConfiguration = true; - services.syncthing = { - enable = true; - openDefaultPorts = true; - systemService = true; - user = "anish"; - dataDir = "/home/anish/usr/syncthing"; - }; - - #zsh powerlevel10k - programs.zsh.enable = true; - programs.zsh.promptInit = "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; - users.users.anish.shell = pkgs.zsh; - - #android - programs.adb.enable = true; - users.users.anish.extraGroups = ["adbusers"]; - -} diff --git a/modules/dns.nix b/modules/dns.nix deleted file mode 100644 index c08693c8..00000000 --- a/modules/dns.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, lib, ... }: -{ - services.dnsmasq.enable = true; - services.dnsmasq.extraConfig = '' - address=/.mossnet.lan/192.168.1.6 - dhcp-range=192.168.1.1,proxy - ''; - services.dnsmasq.servers = [ "45.90.30.49" "45.90.28.49" "1.1.1.1" "8.8.8.8" ]; - networking.firewall.allowedTCPPorts = [ 53 ]; - networking.firewall.allowedUDPPorts = [ 53 ]; -} diff --git a/modules/headphones.nix b/modules/headphones.nix deleted file mode 100644 index a76c6d5d..00000000 --- a/modules/headphones.nix +++ /dev/null @@ -1,12 +0,0 @@ -{config, lib, pkgs, ... }: -{ - services.headphones = { - enable = true; - host = "192.168.1.6"; - port = 8181; - user = "headphones"; - group = "headphones"; - dataDir = "/data/downloaded"; - }; - networking.firewall.allowedTCPPorts = [ 8181 ]; -} diff --git a/modules/hm-system-defaults.nix b/modules/hm-system-defaults.nix new file mode 100644 index 00000000..7b442a61 --- /dev/null +++ b/modules/hm-system-defaults.nix @@ -0,0 +1,11 @@ +{ config, ... }: { + home-manager.sharedModules = [ + { + home.sessionVariables = { + inherit (config.environment.sessionVariables) NIX_PATH; + }; + xdg.configFile."nix/registry.json".text = + config.environment.etc."nix/registry.json".text; + } + ]; +} diff --git a/modules/matrix-slack.nix b/modules/matrix-slack.nix deleted file mode 100644 index b3b071c2..00000000 --- a/modules/matrix-slack.nix +++ /dev/null @@ -1,153 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; - -let - dataDir = "/var/lib/matrix-appservice-slack"; - registrationFile = "${dataDir}/slack-registration.yaml"; - #appDir = "${pkgs.matrix-appservice-slack}/${pkgs.matrix-appservice-slack.passthru.nodeAppDir}"; - cfg = config.services.matrix-appservice-slack; - # TODO: switch to configGen.json once RFC42 is implemented - settingsFile = pkgs.writeText "matrix-appservice-slack-settings.json" (builtins.toJSON cfg.settings); - -in { - options = { - services.matrix-appservice-slack = { - enable = mkEnableOption "a bridge between Matrix and Slack"; - - settings = mkOption rec { - # TODO: switch to types.config.json as prescribed by RFC42 once it's implemented - type = types.attrs; - apply = recursiveUpdate default; - default = { - # empty values necessary for registration file generation - # actual values defined in environmentFile - auth = { - clientID = ""; - botToken = ""; - }; - }; - example = literalExample '' - { - bridge = { - domain = "public-domain.tld"; - homeserverUrl = "http://public-domain.tld:8008"; - }; - } - ''; - description = '' - config.yaml configuration as a Nix attribute set. - - - - Configuration options should match those described in - - config.sample.yaml. - - - - and - should be set to match the public host name of the Matrix homeserver for webhooks and avatars to work. - - - - Secret tokens should be specified using - instead of this world-readable attribute set. - ''; - }; - - environmentFile = mkOption { - type = types.nullOr types.path; - default = null; - description = '' - File containing environment variables to be passed to the matrix-appservice-discord service, - in which secret tokens can be specified securely by defining values for - APPSERVICE_SLACK_AUTH_CLIENT_I_D and - APPSERVICE_SLACK_AUTH_BOT_TOKEN. - ''; - }; - - url = mkOption { - type = types.str; - default = "http://localhost:${toString cfg.port}"; - description = '' - The URL where the application service is listening for HS requests. - ''; - }; - - port = mkOption { - type = types.port; - default = 9898; # from https://github.com/matrix-org/matrix-appservice-slack/blob/develop/config/config.sample.yaml#L70 - description = '' - Port number on which the bridge should listen for internal communication with the Matrix homeserver. - ''; - }; - - localpart = mkOption { - type = with types; nullOr str; - default = null; - description = '' - The user_id localpart to assign to the AS. - ''; - }; - - serviceDependencies = mkOption { - type = with types; listOf str; - default = optional config.services.matrix-synapse.enable "matrix-synapse.service"; - description = '' - List of Systemd services to require and wait for when starting the application service, - such as the Matrix homeserver if it's running on the same host. - ''; - }; - }; - }; - - config = mkIf cfg.enable { - systemd.services.matrix-appservice-slack = { - description = "A bridge between Matrix and Slack."; - - wantedBy = [ "multi-user.target" ]; - wants = [ "network-online.target" ] ++ cfg.serviceDependencies; - after = [ "network-online.target" ] ++ cfg.serviceDependencies; - - preStart = '' - if [ ! -f '${registrationFile}' ]; then - ${pkgs.matrix-appservice-slack}/bin/matrix-appservice-slack \ - --generate-registration \ - --url=${escapeShellArg cfg.url} \ - ${optionalString (cfg.localpart != null) "--localpart=${escapeShellArg cfg.localpart}"} \ - --config='${settingsFile}' \ - --file='${registrationFile}' - fi - ''; - - serviceConfig = { - Type = "simple"; - Restart = "always"; - - ProtectSystem = "strict"; - ProtectHome = true; - ProtectKernelTunables = true; - ProtectKernelModules = true; - ProtectControlGroups = true; - - DynamicUser = true; - PrivateTmp = true; - #WorkingDirectory = appDir; - StateDirectory = baseNameOf dataDir; - UMask = 0027; - EnvironmentFile = cfg.environmentFile; - - ExecStart = '' - ${pkgs.matrix-appservice-slack}/bin/matrix-appservice-slack \ - --file='${registrationFile}' \ - --config='${settingsFile}' \ - --port='${toString cfg.port}' - ''; - }; - }; - }; - - meta.maintainers = with maintainers; [ chickensoupandrice ]; -} - diff --git a/modules/matrix.nix b/modules/matrix.nix deleted file mode 100644 index 32330aac..00000000 --- a/modules/matrix.nix +++ /dev/null @@ -1,258 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - imports = [ ./matrix-slack.nix ./mautrix-whatsapp.nix ]; - security.acme.email = "anish+acme@lakhwara.com"; - security.acme.acceptTerms = true; - services.matrix-synapse = { - enable = true; - app_service_config_files = [ - # # The registration file is automatically generated after starting the appservice for the first time. - # # cp /var/lib/matrix-appservice-discord/discord-registration.yaml /var/lib/matrix-synapse/ - # # chown matrix-synapse:matrix-synapse /var/lib/matrix-synapse/discord-registration.yaml - # "/var/lib/matrix-synapse/discord-registration.yaml" - "/var/lib/matrix-synapse/telegram-registration.yaml" - "/var/lib/matrix-synapse/slack-registration.yaml" - "/var/lib/matrix-synapse/whatsapp-registration.yaml" - ]; - server_name = "sealight.xyz"; - registration_shared_secret = "hD9HQGTTDxp0mQsQ5JDsfudWMDiubmZENOgPchIvfBvUlPxlvQSvjoO4wn2L1seU"; - enable_metrics = true; - enable_registration = true; - database_type = "psycopg2"; - database_args = { - database = "matrix-synapse"; - }; - listeners = [ - { - port = 8448; - tls = false; - resources = [ - { - compress = true; - names = ["client" "federation"]; - } - ]; - } - ]; - extraConfig = '' - max_upload_size: "50M" - ''; - }; - - services.mautrix-telegram = { - enable = true; - environmentFile = /etc/secrets/telegram.env; # file containing the appservice and telegram tokens - # The appservice is pre-configured to use SQLite by default. It's also possible to use PostgreSQL. - settings = { - homeserver = { - address = "https://chat.sealight.xyz"; - domain = "sealight.xyz"; - }; - appservice = { - provisioning.enabled = false; - id = "telegram"; - public = { - enabled = false; - prefix = "/public"; - external = "https://chat.sealight.xyz/public"; - }; - # The service uses SQLite by default, but it's also possible to use PostgreSQL instead: - #database = "postgresql:///mautrix-telegram?host=/run/postgresql"; - }; - bridge = { - relaybot.authless_portals = false; - permissions = { - "@aynish:sealight.xyz" = "admin"; - }; - }; - }; - }; - - services.mautrix-whatsapp = { - enable = true; - # The appservice is pre-configured to use SQLite by default. It's also possible to use PostgreSQL. - configOptions = { - homeserver = { - address = "https://chat.sealight.xyz"; - domain = "sealight.xyz"; - }; - appservice = { - id = "whatsapp"; - address = http://localhost:9897; - hostname = "0.0.0.0"; - port = 9897; - database = { - type = "sqlite3"; - uri = "/var/lib/mautrix-whatsapp/mautrix-whatsapp.db"; - }; - state_store_path = "/var/lib/mautrix-whatsapp/mx-state.json"; - bot = { - username = "whatsappbot"; - displayname = "WhatsApp bridge bot"; - avatar = "mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr"; - }; - as_token = ""; - hs_token = ""; - }; - bridge = { - username_template = "whatsapp_{{.}}"; - displayname_template = "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)"; - command_prefix = "!wa"; - permissions = { - "@aynish:sealight.xyz" = 100; - }; - }; - logging = { - directory = "/var/lib/mautrix-whatsapp/logs"; - file_name_format = "{{.Date}}-{{.Index}}.log"; - file_date_format = "\"2006-01-02\""; - file_mode = 384; - timestamp_format = "Jan _2, 2006 15:04:05"; - print_level = "debug"; - }; - metrics = { - enabled = true; - listen = "http://localhost:5070"; - }; - }; - }; - - services.matrix-appservice-slack = { - enable = true; - #environmentFile = /etc/secrets/matrix-appservice-slack.env; - settings = { - homeserver = { - server_name = "sealight.xyz"; - url = "https://chat.sealight.xyz"; - }; - db = { - engine = "postgres"; - connectionString = "postgres://slackbridge_user:somethingverysecret@localhost/slack_bridge?sslmode=require"; - }; - matrix_admin_room = "!ikEWOHCcmoZtVzSmPF:sealight.xyz"; - username_prefix = "slack_"; - rtm = { - enable = true; - logging = "silent"; - }; - slack_hook_port = 9899; - enable_metrics = true; - puppeting = { - enabled = true; - onboard_users = true; - }; - oauth2 = { - client_id = "2832868673.1609454840563"; - client_secret = "079a7ca42b192e66a9ff32740a69cb9d"; - redirect_prefix = "https://sealight.xyz/slackbridge/"; - }; - #team_sync = { - # T02QGRJKT = { - # users = { - # enabled = false; - # }; - # channels = { - # enabled = true; - # alias_prefix = "qf_"; - # }; - # }; - #}; - }; - }; - - services.postgresql = { - enable = true; - ## postgresql user and db name remains in the - ## service.matrix-synapse.database_args setting which - ## by default is matrix-synapse - initialScript = pkgs.writeText "synapse-init.sql" '' - CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD "Da0?H*9i{x?,]|'kq@iBwlIzu"; - CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" - TEMPLATE template0 - LC_COLLATE = "C" - LC_CTYPE = "C"; - ''; - }; - - networking.firewall = { - enable = true; - allowedTCPPorts = [ - 22 # SSH - 8448 # Matrix federation - 8008 - 80 - 443 - 9899 # Matrix <-> Slack Bridge Puppeting - ]; - }; - - nixpkgs.overlays = [ - (self: super: { - element-web = super.element-web.override { - conf = { - default_server_config = { - "m.homeserver" = { - "base_url" = "https://chat.sealight.xyz"; - "server_name" = "sealight.xyz"; - }; - "m.identity_server" = { - "base_url" = "https://vector.im"; - }; - }; - - ## jitsi will be setup later, - ## but we need to add to Riot configuration - #jitsi.preferredDomain = "jitsi.dangerousdemos.net"; - }; - }; - }) - ]; - - services.nginx = { - enable = true; - virtualHosts = { - - "sealight.xyz" = { - forceSSL = true; - enableACME = true; - locations."/" = { - root = "/var/www/sealight.xyz"; - }; - locations."/_matrix" = { - proxyPass = "http://localhost:8448"; - }; - locations."/slackbridge" = { - proxyPass = "http://localhost:9899"; - }; - }; - ## virtual host for Synapse - "chat.sealight.xyz" = { - forceSSL = true; - enableACME = true; - #useACMEHost = "sealight.xyz"; - locations."/" = { - proxyPass = "http://localhost:8448"; - }; - }; - - ## virtual host for Riot/Web - "element.sealight.xyz" = { - forceSSL = true; - enableACME = true; - #useACMEHost = "sealight.xyz"; - - ## root points to the riot-web package content, also configured via Nix - locations."/" = { - root = pkgs.element-web; - }; - }; - }; - ## other nginx specific best practices - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedTlsSettings = true; - }; - - environment.systemPackages = with pkgs; [ matrix-appservice-slack ]; -} diff --git a/modules/mautrix-whatsapp.nix b/modules/mautrix-whatsapp.nix deleted file mode 100644 index beaaa6f0..00000000 --- a/modules/mautrix-whatsapp.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.services.mautrix-whatsapp; - - configFile = pkgs.runCommand "mautrix-whatsapp" { - buildInputs = [ pkgs.mautrix-whatsapp pkgs.remarshal ]; - preferLocalBuild = true; - } '' - mkdir -p $out - ${pkgs.remarshal}/bin/json2yaml -i ${pkgs.writeText "config.json" (builtins.toJSON cfg.configOptions)} \ - -o $out/config.yaml - - ${pkgs.mautrix-whatsapp}/bin/mautrix-whatsapp -c $out/config.yaml -g -r $out/registration.yaml - ''; - -in -{ - options.services.mautrix-whatsapp = { - enable = mkEnableOption "Mautrix-whatsapp, a puppeting bridge between Matrix and WhatsApp."; - - configOptions = mkOption { - type = types.attrs; - description = '' - This options will be transform in YAML configuration file for the bridge - - Look here for documentation. - ''; - example = { - configOptions = { - homeserver = { - address = https://matrix.org; - domain = "matrix.org"; - }; - appservice = { - address = http://localhost:8080; - hostname = "0.0.0.0"; - port = 8080; - database = { - type = "sqlite3"; - uri = "/var/lib/mautrix-whatsapp/mautrix-whatsapp.db"; - }; - state_store_path = "/var/lib/mautrix-whatsapp/mx-state.json"; - id = "whatsapp"; - bot = { - username = "whatsappbot"; - displayname = "WhatsApp bridge bot"; - avatar = "mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr"; - }; - as_token = ""; - hs_token = ""; - }; - bridge = { - username_template = "whatsapp_{{.}}"; - displayname_template = "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)"; - command_prefix = "!wa"; - permissions = { - "@example:matrix.org" = 100; - }; - }; - logging = { - directory = "/var/lib/mautrix-whatsapp/logs"; - file_name_format = "{{.Date}}-{{.Index}}.log"; - file_date_format = "\"2006-01-02\""; - file_mode = 384; - timestamp_format = "Jan _2, 2006 15:04:05"; - print_level = "debug"; - }; - }; - }; - }; - }; - - config = mkIf cfg.enable { - systemd.services.mautrix-whatsapp = { - description = "Mautrix-WhatsApp Service - A WhatsApp bridge for Matrix"; - after = [ "network.target" "matrix-synapse.service" ]; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - DynamicUser = true; - StateDirectory = "mautrix-whatsapp"; - LoggingDir = "mautrix-whatsapp"; - ExecStart = '' - ${pkgs.mautrix-whatsapp}/bin/mautrix-whatsapp -c "${configFile}/config.yaml" - ''; - Restart = "on-failure"; - }; - }; - - #services.matrix-synapse.app_service_config_files = [ "${configFile}/registration.yaml" ]; - - }; -} diff --git a/modules/mod-shaarli.nix b/modules/mod-shaarli.nix deleted file mode 100644 index b3e0b52c..00000000 --- a/modules/mod-shaarli.nix +++ /dev/null @@ -1,80 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - phppoolName = "shaarli"; - dataDir = "/var/lib/shaarli"; - vhost = "192.168.1.6:1233"; - - shaarli = pkgs.callPackage ./pkg-shaarli.nix { - inherit dataDir; - }; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "${shaarli}"; - listen = [ { addr = "192.168.1.6"; port = 1233; } ]; - # extraConfig = '' - # index index.php; - # ''; - locations."/" = { - index = "index.php"; - extraConfig = '' - try_files $uri $uri/ index.php; - ''; - }; - locations."~ (index)\.php$" = { - extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - include ${pkgs.nginx}/conf/fastcgi.conf; - fastcgi_pass unix:${config.services.phpfpm.pools."${phppoolName}".socket}; - fastcgi_index index.php; - ''; - }; - locations."~ \.php$" = { - extraConfig = '' - deny all; - ''; - }; - }; - services.phpfpm.pools."${phppoolName}" = { - user = "nginx"; - group = "nginx"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "nginx"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - }; - }; - users.extraUsers.shaarli = { group = "shaarli"; }; - users.extraGroups.shaarli = { }; - systemd.services.shaarli-install = { - serviceConfig.Type = "oneshot"; - wantedBy = [ "multi-user.target" ]; - script = '' - if [ ! -d "${dataDir}" ]; then - mkdir -p ${dataDir}/{cache,data,pagecache,tmp} - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/cache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/data/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/tmp/ - fi - chown -Rc nginx:nginx ${dataDir} - find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; - find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; - ''; - }; - - networking.firewall.allowedTCPPorts = [ 1233 ]; -} diff --git a/modules/mod-wallabag.nix b/modules/mod-wallabag.nix deleted file mode 100644 index fc6f7ff1..00000000 --- a/modules/mod-wallabag.nix +++ /dev/null @@ -1,263 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -let - cfg = config.services.wallabag; - - poolName = "wallabag"; - - phpfpmSocketName = "/var/run/phpfpm/${poolName}.sock"; - - configFile = pkgs.writeTextFile { - name = "wallabag-config"; - text = cfg.conf; - destination = "/config/parameters.yml"; - }; - - appDir = pkgs.buildEnv { - name = "wallabag-app-dir"; - ignoreCollisions = true; - checkCollisionContents = false; - paths = [ configFile "${cfg.package}/app" ]; - }; - -in { - options = { - services.wallabag = { - enable = mkEnableOption "wallabag"; - - user = mkOption { - type = types.str; - default = "nginx"; - description = '' - User account under which both the update daemon and the web-application run. - ''; - }; - - dataDir = mkOption { - type = types.path; - default = "/var/www/wallabag"; - description = '' - Data directory. - ''; - }; - - package = mkOption { - type = types.package; - default = pkgs.wallabag; - description = '' - Wallabag package to use. - ''; - }; - - hostName = mkOption { - type = types.str; - description = '' - Name of the nginx virtualhost to use and setup. - ''; - }; - - poolConfig = mkOption { - type = types.lines; - default = '' - pm = dynamic - pm.max_children = 75 - pm.start_servers = 1 - pm.min_spare_servers = 1 - pm.max_spare_servers = 20 - pm.max_requests = 500 - catch_workers_output = 1 - ''; - description = '' - Options for wallabag's PHP pool. See the documentation on php-fpm.conf for details on configuration directives. - ''; - }; - - conf = mkOption { - type = types.str; - default = '' -parameters: - database_driver: pdo_pgsql - database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver - database_host: 127.0.0.1 - database_port: ~ - database_name: wallabag - database_user: wallabag - database_password: ~ - # For SQLite, database_path should be "%kernel.project_dir%/data/db/wallabag.sqlite" - database_path: null - database_table_prefix: wallabag_ - database_socket: null - # with PostgreSQL and SQLite, you must set "utf8" - database_charset: utf8 - - domain_name: http://192.168.1.6:8080 - - mailer_transport: smtp - mailer_user: ~ - mailer_password: ~ - mailer_host: 127.0.0.1 - mailer_port: false - mailer_encryption: ~ - mailer_auth_mode: ~ - locale: en - # A secret key that's used to generate certain security-related tokens - secret: sateofg893964crfSTNFG"*(&@$091 - twofactor_auth: true - twofactor_sender: no-reply@wallabag.org - fosuser_registration: true - fosuser_confirmation: true - fos_oauth_server_access_token_lifetime: 3600 - fos_oauth_server_refresh_token_lifetime: 1209600 - from_email: no-reply@wallabag.org - rss_limit: 50 - rabbitmq_host: localhost - rabbitmq_port: 5672 - rabbitmq_user: ~ - rabbitmq_password: ~ - rabbitmq_prefetch_count: 0 - redis_scheme: tcp - redis_host: localhost - redis_port: 6379 - redis_path: ~ - redis_password: ~ - sentry_dsn: ~ -''; - description = '' - Contents of the wallabag configuration file (parameters.yml) - ''; - }; - }; - }; - - - config = mkIf cfg.enable { - - services.phpfpm.pools."${poolName}" = { - user = "${cfg.user}"; - group = "nginx"; - settings = { - "listen" = "${phpfpmSocketName}"; - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "listen.mode" = "0600"; - "env[WALLABAG_DATA]" = "${cfg.dataDir}"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - }; - }; - services.phpfpm.phpOptions = '' - max_execution_time = 120 - ''; - - services.nginx.enable = mkDefault true; - - services.nginx.virtualHosts."${cfg.hostName}" = { - root = "${cfg.package}/web"; - listen = [ { addr = "192.168.1.6"; port = 8080; } ]; - - extraConfig = '' - add_header X-Frame-Options SAMEORIGIN; - add_header X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - ''; - - locations."/" = { - extraConfig = '' - try_files $uri /app.php$is_args$args; - ''; - }; - - locations."/assets".root = "${cfg.dataDir}/web"; - - locations."~ ^/app\\.php(/|$)" = { - extraConfig = '' - fastcgi_pass unix:${phpfpmSocketName}; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include ${pkgs.nginx}/conf/fastcgi_params; - - fastcgi_param SCRIPT_FILENAME ${cfg.package}/web/$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT ${cfg.package}/web; - fastcgi_read_timeout 120; - - internal; - ''; - }; - - locations."~ /(?!app)\\.php$" = { - extraConfig = '' - return 404; - ''; - }; - }; - - services.postgresql = { - enable = true; - - # Ensure the database, user, and permissions always exist - ensureDatabases = [ "wallabag" "wallabag_user" ]; - authentication = lib.mkForce '' - # Generated file; do not edit! - # TYPE DATABASE USER ADDRESS METHOD - local all all trust - host all wallabag 127.0.0.1/32 trust - ''; - ensureUsers = [ - { name = "wallabag"; - ensurePermissions."DATABASE wallabag" = "ALL PRIVILEGES"; - ensurePermissions."DATABASE wallabag_user" = "ALL PRIVILEGES"; - } - ]; - }; - - systemd.services.wallabag-install = { - description = "Wallabag install service"; - wantedBy = [ "multi-user.target" ]; - before = [ "phpfpm-wallabag.service" ]; - after = [ "mysql.service" "postgresql.service" ]; - path = with pkgs; [ coreutils php72 php72Packages.composer ]; - - serviceConfig = { - User = cfg.user; - Type = "oneshot"; - RemainAfterExit = "yes"; - PermissionsStartOnly = true; - }; - - preStart = '' - mkdir -p "${cfg.dataDir}" - chown ${cfg.user}:nginx "${cfg.dataDir}" - ''; - - script = '' - echo "Setting up wallabag files in ${cfg.dataDir} ..." - cd "${cfg.dataDir}" - - rm -rf var/cache/* - rm -f app - ln -sf ${appDir} app - ln -sf ${cfg.package}/composer.{json,lock} . - - export WALLABAG_DATA="${cfg.dataDir}" - if [ ! -f installed ]; then - php ${cfg.package}/bin/console --env=prod doctrine:database:create --if-not-exists --no-interaction - #php ${cfg.package}/bin/console --env=prod doctrine:migrations:migrate --no-interaction - # Until https://github.com/wallabag/wallabag/issues/3662 is fixed - yes no | php ${cfg.package}/bin/console --env=prod wallabag:install - touch installed - else - php ${cfg.package}/bin/console --env=prod doctrine:migrations:migrate --no-interaction - fi - php ${cfg.package}/bin/console --env=prod cache:clear - ''; - }; - }; - - meta = with stdenv.lib; { - maintainers = with maintainers; [ chickensoupwithrice ]; - }; -} diff --git a/modules/monitoring-helix.nix b/modules/monitoring-helix.nix deleted file mode 100644 index b7b0c6ca..00000000 --- a/modules/monitoring-helix.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, pkgs, ... }: { - # grafana configuration - services.grafana = { - enable = true; - domain = "grafana.sealight.xyz"; - port = 2342; - addr = "127.0.0.1"; - }; - - # nginx reverse proxy - services.nginx.virtualHosts.${config.services.grafana.domain} = { - locations."/" = { - proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}"; - proxyWebsockets = true; - }; - }; -} diff --git a/modules/monitoring.nix b/modules/monitoring.nix deleted file mode 100644 index c5683289..00000000 --- a/modules/monitoring.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ config, pkgs, ... }: { - # grafana configuration - services.grafana = { - enable = true; - domain = "grafana.mossnet.lan"; - port = 2342; - addr = "127.0.0.1"; - }; - - # nginx reverse proxy - services.nginx.virtualHosts.${config.services.grafana.domain} = { - locations."/" = { - proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}"; - proxyWebsockets = true; - }; - }; - - services.prometheus = { - enable = true; - port = 9001; - exporters = { - node = { - enable = true; - enabledCollectors = [ "systemd" ]; - port = 9002; - }; - }; - scrapeConfigs = [ - { - job_name = "bowl"; - static_configs = [{ - targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; - }]; - } - ]; - }; - - services.loki = { - enable = true; - configFile = /var/loki-config.yaml; - }; - - systemd.services.promtail = { - description = "Promtail service for Loki"; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - ExecStart = '' - ${pkgs.grafana-loki}/bin/promtail --config.file ${/var/promtail.yaml} - ''; - }; - }; -} diff --git a/modules/navidrome.nix b/modules/navidrome.nix deleted file mode 100644 index be4fe9c5..00000000 --- a/modules/navidrome.nix +++ /dev/null @@ -1,101 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.services.navidrome; - configFile = "/etc/navidrome/settings.json"; - dataFolder = "/var/lib/navidrome"; -in { - options = { - - services.navidrome = { - enable = mkEnableOption "Navidrome music server and streamer"; - - settings = lib.mkOption { - type = with types; attrsOf (oneOf [ int str ]); - default = {}; - example = literalExample '' - { - LogLevel = "INFO"; - BaseURL = "/music"; - ScanInterval = "10s"; - TranscodingCacheSize = "15MB"; - MusicFolder = "/data/music"; - }; - ''; - description = '' - Configuration for Navidrome, see for supported values. - ''; - }; - - user = mkOption { - type = types.str; - default = "navidrome"; - description = "User account under which Navidrome runs."; - }; - - group = mkOption { - type = types.str; - default = "navidrome"; - description = "Group account under which Navidrome runs."; - }; - - }; - }; - - config = mkIf cfg.enable { - - environment.etc."navidrome/settings.json".text = builtins.toJSON cfg.settings; - - services.navidrome.settings = { - DataFolder = dataFolder; - ConfigFile = configFile; - }; - - systemd.services.navidrome = { - description = "Navidrome Music Server and Streamer compatible with Subsonic/Airsonic"; - after = [ "remote-fs.target" "network.target" ]; - wantedBy = [ "multi-user.target" ]; - environment = { - ND_CONFIGFILE = configFile; - }; - serviceConfig = { - ExecStart = "${pkgs.navidrome}/bin/navidrome"; - WorkingDirectory = dataFolder; - TimeoutStopSec = "20"; - KillMode = "process"; - Restart = "on-failure"; - User = cfg.user; - Group = cfg.group; - DevicePolicy = "closed"; - NoNewPrivileges= " yes"; - PrivateTmp = "yes"; - PrivateUsers = "yes"; - ProtectControlGroups = "yes"; - ProtectKernelModules = "yes"; - ProtectKernelTunables = "yes"; - RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6"; - RestrictNamespaces = "yes"; - RestrictRealtime = "yes"; - SystemCallFilter = "~@clock @debug @module @mount @obsolete @privileged @reboot @setuid @swap"; - ReadWritePaths = dataFolder; - StateDirectory = baseNameOf dataFolder; - }; - }; - - users.users = optionalAttrs (cfg.user == "navidrome") ({ - navidrome = { - description = "Navidrome service user"; - name = cfg.user; - group = cfg.group; - isSystemUser = true; - }; - }); - - users.groups = optionalAttrs (cfg.group == "navidrome") ({ - navidrome = {}; - }); - - }; -} diff --git a/modules/nextcloud.nix b/modules/nextcloud.nix deleted file mode 100644 index c1919b80..00000000 --- a/modules/nextcloud.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ pkgs, config, ... }: -{ - services.nextcloud = { - enable = true; - hostName = "mossnet.lan"; - #home = "/data/nextcloud"; - - # Use HTTPS for links - https = false; - - # Auto-update Nextcloud Apps - autoUpdateApps.enable = true; - # Set what time makes sense for you - autoUpdateApps.startAt = "05:00:00"; - - config = { - # Further forces Nextcloud to use HTTPS - # overwriteProtocol = "https"; - - # Nextcloud PostegreSQL database configuration, recommended over using SQLite - dbtype = "pgsql"; - dbuser = "nextcloud"; - dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself - dbname = "nextcloud"; - dbpassFile = "/var/nextcloud-db-pass"; - - adminpassFile = "/var/nextcloud-admin-pass"; - adminuser = "admin"; - }; - }; - - # Enable PostgreSQL - services.postgresql = { - enable = true; - - # Ensure the database, user, and permissions always exist - ensureDatabases = [ "nextcloud" ]; - ensureUsers = [ - { name = "nextcloud"; - ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; - } - ]; - }; - - # Ensure that postgres is running before running the setup - systemd.services."nextcloud-setup" = { - requires = ["postgresql.service"]; - after = ["postgresql.service"]; - }; - - networking.firewall.allowedTCPPorts = [ 80 443 ]; -} diff --git a/modules/nix-path.nix b/modules/nix-path.nix new file mode 100644 index 00000000..273f67a6 --- /dev/null +++ b/modules/nix-path.nix @@ -0,0 +1,7 @@ +{ channel, inputs, ... }: { + nix.nixPath = [ + "nixpkgs=${channel.input}" + "nixos-config=${../lib/compat/nixos}" + "home-manager=${inputs.home}" + ]; +} diff --git a/modules/nvim.nix b/modules/nvim.nix deleted file mode 100644 index 3fd1153f..00000000 --- a/modules/nvim.nix +++ /dev/null @@ -1,261 +0,0 @@ -{ pkgs, ... }: - - - #nvim - { - environment.variables.EDITOR = "nvim"; - environment.shellAliases = { - k = "vim -c :VimwikiIndex"; - kz = "vim -c :VimwikiIndex -c :ZettelNew"; - }; - environment.systemPackages = with pkgs; [ - nodejs - ( neovim.override { - vimAlias = true; - configure = { - packages.myPlugins = with pkgs.vimPlugins; { - start = [ - vim-nix - fzf-vim - vim-elixir - emmet-vim - nerdtree - goyo-vim - vim-sneak - lightline-vim - csv-vim - vimwiki - coc-nvim - coc-json - coc-python - coc-pairs - coc-emmet - emmet-vim - LanguageClient-neovim - ayu-vim - rainbow_parentheses-vim - vim-surround - vim-fugitive - #iron-nvim - #nvim-colorizer - vim-devicons - # testing - #vim-processing - #vim-tidal - taskwiki - vim-zettel - #vimwiki-sync - ]; - }; - customRC = '' - set tabstop=2 - set showmatch - set shiftwidth=2 - set noexpandtab - set autoindent - - set foldmethod=indent " fold based on indent - set number - set nocompatible - set relativenumber - set showtabline=2 - set autowriteall - syntax on - set list lcs=tab:\|\ - filetype plugin on - - set termguicolors - let ayucolor="dark" - colorscheme ayu - - " window - nmap wh :topleft vnew - nmap wl :botright vnew - nmap wk :topleft new - nmap wj :botright new - - let mapleader = "\" - - " lightline colorscheme - let g:lightline = { - \ 'colorscheme': 'seoul256', - \ } - - " moving splits with vim movements. - :tnoremap h - :tnoremap j - :tnoremap k - :tnoremap l - :inoremap h - :inoremap j - :inoremap k - :inoremap l - :nnoremap h - :nnoremap j - :nnoremap k - :nnoremap l - :nnoremap "=strftime("%Y-%m-%d %H:%M:") - :inoremap =strftime("%Y-%m-%d %H:%M:") - - " exit normal mode in terminal - :tnoremap - - let g:syntastic_always_populate_loc_list = 1 - let g:syntastic_auto_loc_list = 1 - let g:syntastic_check_on_open = 1 - let g:syntastic_check_on_wq = 0 - - let g:rainbow_active = 0 - autocmd BufReadPost,BufNewFile c,py,nix RainbowParenthesesToggleAll - - " keyboard commands - map t :NERDTreeToggle - map s :w - map q :wq - map r :RainbowParenthesesToggleAll - map zs :ZettelSearch - map zo :ZettelOpen - map zn :ZettelNew - - - " NERDTree - " open on directory - autocmd StdinReadPre * let s:std_in=1 - - " coc - " - " if hidden is not set, TextEdit might fail. - set hidden - - " Some servers have issues with backup files, see #649 - set nobackup - set nowritebackup - - " Better display for messages - set cmdheight=2 - - " You will have bad experience for diagnostic messages when it's default 4000. - set updatetime=300 - - " don't give |ins-completion-menu| messages. - set shortmess+=c - - " always show signcolumns - set signcolumn=yes - - " Use tab for trigger completion with characters ahead and navigate. - " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. - inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() - inoremap pumvisible() ? "\" : "\" - - function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' - endfunction - - " Use to trigger completion. - inoremap coc#refresh() - - " Use to confirm completion, `u` means break undo chain at current position. - " Coc only does snippet and additional edit on confirm. - inoremap pumvisible() ? "\" : "\u\" - " Or use `complete_info` if your vim support it, like: - " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - - " Use `[g` and `]g` to navigate diagnostics - nmap [g (coc-diagnostic-prev) - nmap ]g (coc-diagnostic-next) - - " Remap keys for gotos - nmap gd (coc-definition) - nmap gy (coc-type-definition) - nmap gi (coc-implementation) - nmap gr (coc-references) - - " Use K to show documentation in preview window - nnoremap K :call show_documentation() - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif - endfunction - - " Highlight symbol under cursor on CursorHold - autocmd CursorHold * silent call CocActionAsync('highlight') - - " Remap for rename current word - nmap rn (coc-rename) - - " Remap for format selected region - xmap f (coc-format-selected) - nmap f (coc-format-selected) - - augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') - augroup end - - " Remap for do codeAction of selected region, ex: `aap` for current paragraph - xmap a (coc-codeaction-selected) - nmap a (coc-codeaction-selected) - - " Remap for do codeAction of current line - nmap ac (coc-codeaction) - " Fix autofix problem of current line - nmap qf (coc-fix-current) - - " Create mappings for function text object, requires document symbols feature of languageserver. - xmap if (coc-funcobj-i) - xmap af (coc-funcobj-a) - omap if (coc-funcobj-i) - omap af (coc-funcobj-a) - - " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python - nmap (coc-range-select) - xmap (coc-range-select) - - " Use `:Format` to format current buffer - command! -nargs=0 Format :call CocAction('format') - - " Use `:Fold` to fold current buffer - command! -nargs=? Fold :call CocAction('fold', ) - - " use `:OR` for organize import of current buffer - command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - - " Add status line support, for integration with other plugin, checkout `:h coc-status` - " set statusline^=%{coc#status()}%{get(b:,'coc_current_function',"")} - - " Using CocList - " Show all diagnostics - nnoremap a :CocList diagnostics - " Manage extensions - nnoremap e :CocList extensions - " Show commands - nnoremap c :CocList commands - " Find symbol of current document - nnoremap o :CocList outline - " Search workspace symbols - nnoremap s :CocList -I symbols - " Do default action for next item. - nnoremap j :CocNext - " Do default action for previous item. - nnoremap k :CocPrev - " Resume latest coc list - nnoremap p :CocListResume - - au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl setf glsl - ''; - }; - } - )]; -} diff --git a/modules/sealight.nix b/modules/sealight.nix deleted file mode 100644 index ed882042..00000000 --- a/modules/sealight.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - services.nginx = { - enable = true; - vhost = { - "sealight.xyz" = { - forceSSL = true; - enableACME = true; - locations."/" = { - root = "/var/www/sealight.xyz" - }; - }; - }; - }; -} diff --git a/modules/shaarli.nix b/modules/shaarli.nix deleted file mode 100644 index d773bca6..00000000 --- a/modules/shaarli.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ pkgs, config, ... }: -let - dataDir = "/var/www/shaarli-config"; - name = "shaarli"; -in -{ - services.nginx = { - enable = true; - virtualHosts = { - "links.mossnet.lan" = { - forceSSL = false; - enableACME = false; - root = "${dataDir}"; - #listen = [ { addr = "192.168.1.6"; port = 1234; } ]; - extraConfig = '' - index index.php; - ''; - locations = { - "/".extraConfig = '' - try_files $uri $uri/ index.php; - ''; - - "~ (index)\.php$".extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - fastcgi_pass unix:${config.services.phpfpm.pools."${name}".socket}; - fastcgi_index index.php; - - fastcgi_param QUERY_STRING $query_string; - fastcgi_param REQUEST_METHOD $request_method; - fastcgi_param CONTENT_TYPE $content_type; - fastcgi_param CONTENT_LENGTH $content_length; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_param DOCUMENT_URI $document_uri; - fastcgi_param DOCUMENT_ROOT $document_root; - fastcgi_param SERVER_PROTOCOL $server_protocol; - - fastcgi_param GATEWAY_INTERFACE CGI/1.1; - fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; - - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REMOTE_PORT $remote_port; - fastcgi_param SERVER_ADDR $server_addr; - fastcgi_param SERVER_PORT $server_port; - fastcgi_param SERVER_NAME $server_name; - ''; - - "~ \.php$".extraConfig = '' - deny all; - ''; - - "^~ /tpl/".extraConfig = "alias ${pkgs.shaarli}/tpl/;"; - - "^~ /plugins/".extraConfig = "alias ${pkgs.shaarli}/plugins/;"; - - "~* \\.(?:ico|css|js|gif|jpe?g|png)$".extraConfig = '' - expires max; - add_header Pragma public; - add_header Cache-Control "public, must-revalidate, proxy-revalidate"; - ''; - }; - }; - }; - }; - - services.phpfpm = { - pools = { - "${name}" = { - user = "nginx"; - group = "nginx"; - #listen = "/run/phpfpm/php.sock"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "nginx"; - "pm" = "dynamic"; - "pm.max_children" = "4"; - "pm.min_spare_servers" = "1"; - "pm.max_spare_servers" = "4"; - "pm.max_requests" = "32"; - "catch_workers_output" = "1"; - "php_admin_value[error_log]" = "/var/log/nginx/${name}-phpfpm-error.log"; - }; - }; - }; - }; - users.extraUsers."${name}" = { group = "${name}"; }; - users.extraGroups."${name}" = { }; - systemd.services.shaarli-install = { - serviceConfig.Type = "oneshot"; - wantedBy = [ "multi-user.target" ]; - script = '' - if [ ! -d "${dataDir}" ]; then - mkdir -p ${dataDir}/{cache,data,pagecache,tmp} - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/cache/ - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/data/ - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ - cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/tmp/ - ln -S ${pkgs.shaarli}/* ${dataDir} - fi - chown -Rc nginx:nginx ${dataDir} - find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; - find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; - ''; - }; - # TODO: Write the configuration file here? - networking.firewall.allowedTCPPorts = [ 1234 ]; -} diff --git a/modules/taskd.nix b/modules/taskd.nix deleted file mode 100644 index f698a58b..00000000 --- a/modules/taskd.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config, pkgs, ... }: - -{ - services.taskserver.enable = true; - services.taskserver.fqdn = "192.168.1.6"; - services.taskserver.listenHost = "192.168.1.6"; - services.taskserver.listenPort = 53589; - services.taskserver.organisations.mossnet.users = [ "anish" ]; -} - diff --git a/modules/wireguard-helix.nix b/modules/wireguard-helix.nix deleted file mode 100644 index d4c3a84a..00000000 --- a/modules/wireguard-helix.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, pkgs, lib, ... }: -{ - environment.systemPackages = [ pkgs.wireguard pkgs.mosh ]; - networking.nat = { - enable = true; - externalInterface = "ens3"; - internalInterfaces = [ "wg0" ]; - }; - networking.firewall = { - allowedUDPPorts = [ 60990 ]; - }; - - networking.wireguard.interfaces.wg0 = { - ips = [ "10.0.69.1/24" ]; - listenPort = 60990; - privateKeyFile = "/var/lib/wireguard/priv"; - peers = [{ # bowl - publicKey = "EzvDUmHXo95S2jKRv/LkH5ItUNOBgM7aQQsaq1WfCRw="; - allowedIPs = [ "10.0.69.2/32" ]; - } - { # line - publicKey = "ViRabGV2Mv0SZUVWnoAUhIzaHEvqRXAZJLq3Bp1oN1k="; - allowedIPs = [ "10.0.69.3/32" ]; - } -]; - }; -} diff --git a/modules/wireguard.nix b/modules/wireguard.nix deleted file mode 100644 index ebad01c3..00000000 --- a/modules/wireguard.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ config, pkgs, ... }: - -{ - boot.extraModulePackages = with config.boot.kernelPackages; [ wireguard ]; - environment.systemPackages = [ pkgs.wireguard ]; - networking.wireguard.enable = true; - networking.wireguard.interfaces = { - wg0 = { - ips = [ "10.0.69.2/32" ]; - privateKeyFile = "/var/lib/wireguard/priv"; - - peers = [ - { # helix - server - publicKey = "{c1J4p63rD3IlszugMZiki7UBV3YmDdqa3DU4UejXzAI=}"; - allowedIPs = [ "10.0.69.1/24" ]; - endpoint = "sealight.xyz:60990"; - persistentKeepalive = 25; - } ]; - }; - }; -} diff --git a/nixos-legacy-bios-encrypted.sh b/nixos-legacy-bios-encrypted.sh deleted file mode 100644 index e3ed8395..00000000 --- a/nixos-legacy-bios-encrypted.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -set -eux - -hostname="bowl" -password="xxx" - -diskdev=/dev/sda -rootpart=/dev/sda2 - -# -o clear -# -g convert to gpt disk -# -n new partition num:start:end +size -# ef00 EFI / 8300 linux fs -sgdisk -o -g -n 1::+5M -t 1:ef02 -n 2:: -t 2:8300 $diskdev - -# LVM part -echo "$password" | cryptsetup luksFormat --type luks1 -h sha512 $rootpart -echo "$password" | cryptsetup luksOpen $rootpart enc-pv - -pvcreate /dev/mapper/enc-pv -vgcreate vg0 /dev/mapper/enc-pv -lvcreate -L 8G -n swap vg0 -lvcreate -L 40G -n nixos vg0 -lvcreate -l '100%FREE' -n home vg0 - -# format disk -mkfs.ext4 -L root /dev/vg0/nixos -mkfs.ext4 -L home /dev/vg0/home -mkswap -L swap /dev/vg0/swap - -swapon /dev/vg0/swap -mount /dev/vg0/nixos /mnt - -nix-channel --add https://nixos.org/channels/nixos-unstable nixos -nix-channel --update - -nixos-generate-config --root /mnt - -for uuid in /dev/disk/by-uuid/* -do - if test $(readlink -f $uuid) = $rootpart - then - luksuuid=$uuid - break - fi -done - -cat << EOF > /mnt/etc/nixos/configuration.nix -{ config, pkgs, ... }: -{ -imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - boot.loader.grub.devices = [ "/dev/sda" ]; - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.enableCryptodisk = true; - boot.loader.supportsInitrdSecrets = true; - - boot.initrd.kernelModules = [ "dm-snapshot" ]; - boot.initrd.availableKernelModules = ["virtio-pci"]; - boot.initrd.network = { - enable = true; - ssh = { - enable = true; - port = 2222; - authorizedKeys = ["ssh-rsa xxx"]; - hostKeys = [ "/host_ecdsa_key" ]; - }; - }; - - boot.initrd.luks.devices = [ - { - name = "enc-pv"; - preLVM = true; - device = "$luksuuid"; - allowDiscards = true; - } - ]; - - boot.initrd.secrets = { - "/host_ecdsa_key" = "/host_ecdsa_key"; - }; - - boot.cleanTmpDir = true; - boot.kernelModules = [ "dm-snapshot" ]; - nixpkgs.config.allowUnfree = true; - users.users.root.initialHashedPassword = ""; - services.openssh.permitRootLogin = "prohibit-password"; - networking.hostName = "$hostname"; - time.timeZone = "Europe/Paris"; - services.openssh.enable = true; - users.users.root.openssh.authorizedKeys.keys = ["ssh-rsa xxx"]; - system.stateVersion = "20.03"; -} -EOF - -ssh-keygen -t ecdsa -N "" -f host_ecdsa_key - -cp host_ecdsa_key /mnt/ - -nixos-install --no-root-passwd - diff --git a/overlays/manix.nix b/overlays/manix.nix new file mode 100644 index 00000000..d39baa74 --- /dev/null +++ b/overlays/manix.nix @@ -0,0 +1,5 @@ +final: prev: { + manix = prev.manix.overrideAttrs (o: rec{ + inherit (prev.sources.manix) pname version src; + }); +} diff --git a/overlays/overrides.nix b/overlays/overrides.nix new file mode 100644 index 00000000..6280513d --- /dev/null +++ b/overlays/overrides.nix @@ -0,0 +1,28 @@ +channels: final: prev: { + + __dontExport = true; # overrides clutter up actual creations + + inherit (channels.latest) + cachix + dhall + discord + element-desktop + rage + nixpkgs-fmt + qutebrowser + signal-desktop + starship; + + + haskellPackages = prev.haskellPackages.override + (old: { + overrides = prev.lib.composeExtensions (old.overrides or (_: _: { })) (hfinal: hprev: + let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; + in + { + # same for haskell packages, matching ghc versions + inherit (channels.latest.haskell.packages."ghc${version}") + haskell-language-server; + }); + }); +} diff --git a/overlays/various-flake-fixes.nix b/overlays/various-flake-fixes.nix new file mode 100644 index 00000000..7dbfc18b --- /dev/null +++ b/overlays/various-flake-fixes.nix @@ -0,0 +1,11 @@ +final: prev: { + # Since: https://github.com/NixOS/nixpkgs/pull/126137 + nix-direnv = + if builtins.hasAttr "enableFlakes" prev.nix-direnv.override.__functionArgs + then + prev.nix-direnv.override + { + enableFlakes = true; + } + else prev.nix-direnv; +} diff --git a/pkgs/_sources/generated.nix b/pkgs/_sources/generated.nix new file mode 100644 index 00000000..71be3965 --- /dev/null +++ b/pkgs/_sources/generated.nix @@ -0,0 +1,16 @@ +# This file was generated by nvfetcher, please do not modify it manually. +{ fetchgit, fetchurl }: +{ + manix = { + pname = "manix"; + version = "d08e7ca185445b929f097f8bfb1243a8ef3e10e4"; + src = fetchgit { + url = "https://github.com/mlvzk/manix"; + rev = "d08e7ca185445b929f097f8bfb1243a8ef3e10e4"; + fetchSubmodules = false; + deepClone = false; + leaveDotGit = false; + sha256 = "1b7xi8c2drbwzfz70czddc4j33s7g1alirv12dwl91hbqxifx8qs"; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 00000000..924a2300 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,5 @@ +final: prev: { + # keep sources this first + sources = prev.callPackage (import ./_sources/generated.nix) { }; + # then, call packages with `final.callPackage` +} diff --git a/pkgs/pkg-navidrome.nix b/pkgs/pkg-navidrome.nix deleted file mode 100644 index 5bcd3789..00000000 --- a/pkgs/pkg-navidrome.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, lib, pkgs, ... }: -{ - services.navidrome.enable = true; - services.navidrome.settings = { - MusicFolder = "/data/music"; - Port = 4433; - }; - networking.firewall.allowedTCPPorts = [ 4433 ]; -} diff --git a/pkgs/pkg-rssBridge.nix b/pkgs/pkg-rssBridge.nix deleted file mode 100644 index e606c187..00000000 --- a/pkgs/pkg-rssBridge.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib, stdenv, fetchurl, config ? null, dataDir ? "/var/lib/shaarli" }: - -stdenv.mkDerivation rec { - name = "rssBridge-${version}"; - version = "2020-10-11"; - preferLocalBuild = true; - - src = fetchurl { - url = "https://github.com/RSS-Bridge/rss-bridge/archive/${version}.tar.gz"; - sha256 = ""; - }; - - phases = [ "installPhase" ]; - installPhase = '' - mkdir $out - tar xzf $src - cp -ra * $out/ - find $out -type d -exec chmod 0755 {} \; - find $out -type f -exec chmod 0644 {} \; - ln -s $dataDir $out - ''; - - meta = with stdenv.lib; { - description = "RSS-Bridge is a project to create RSS Feeds for websites that don't have one."; - #license = licenses.agpl3; - homepage = "https://github.com/RSS-Bridge/rss-bridge/"; - platforms = platforms.all; - maintainers = with stdenv.lib.maintainers; [ chickensoupwithrice ]; - }; -} diff --git a/pkgs/pkg-shaarli.nix b/pkgs/pkg-shaarli.nix deleted file mode 100644 index be780707..00000000 --- a/pkgs/pkg-shaarli.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ lib, stdenv, fetchurl, config ? null, dataDir ? "/var/lib/shaarli" }: - -stdenv.mkDerivation rec { - name = "shaarli-${version}"; - version = "0.11.1"; - preferLocalBuild = true; - - src = fetchurl { - url = "https://github.com/shaarli/Shaarli/releases/download/v0.11.1/shaarli-v${version}-full.tar.gz"; - sha256 = "1psijcmi24hk0gxh1zdsm299xj11i7find2045nnx3r96cgnwjpn"; - }; - - phases = [ "installPhase" ]; - installPhase = '' - mkdir $out - tar xzf $src - cp -ra Shaarli/. $out/ - find $out -type d -exec chmod 0755 {} \; - find $out -type f -exec chmod 0644 {} \; - for a in cache data pagecache tmp; do - mv $out/$a $out/$a.orig - ln -s "${dataDir}/$a" $out/$a - done - ''; - - meta = with stdenv.lib; { - description = ""; - # License is complicated... - #license = licenses.agpl3; - homepage = "https://github.com/shaarli/Shaarli"; - platforms = platforms.all; - maintainers = with stdenv.lib.maintainers; [ tokudan ]; - }; -} diff --git a/pkgs/pkg-wallabag.nix b/pkgs/pkg-wallabag.nix deleted file mode 100644 index 8e645794..00000000 --- a/pkgs/pkg-wallabag.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkgs, config, lib, ... }: - -{ - services.wallabag = { - enable = true; - hostName = "192.168.1.6:8080"; - }; - networking.firewall.allowedTCPPorts = [ 8080 ]; -} diff --git a/pkgs/sources.toml b/pkgs/sources.toml new file mode 100644 index 00000000..f7af168e --- /dev/null +++ b/pkgs/sources.toml @@ -0,0 +1,4 @@ +# nvfetcher.toml +[manix] +src.git = "https://github.com/mlvzk/manix" +fetch.github = "mlvzk/manix" diff --git a/pkgs/unstable.nix b/pkgs/unstable.nix deleted file mode 100644 index 983a4ed8..00000000 --- a/pkgs/unstable.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, pkgs, ... }: - - -let - unstable = import {}; -in { - nix.nixPath = [ - "nixos-unstable=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz" - ]; - - #currently installed this software through nix-env -f https://nixos.org/channels/nixos-unstable -iA [ packages ] - environment.systemPackages = [ unstable.ripcord ]; -} diff --git a/profiles/cachix/default.nix b/profiles/cachix/default.nix new file mode 100644 index 00000000..d88a3f75 --- /dev/null +++ b/profiles/cachix/default.nix @@ -0,0 +1,11 @@ +{ pkgs, lib, ... }: +let + folder = ./.; + toImport = name: value: folder + ("/" + name); + filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key && key != "default.nix"; + imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); +in +{ + inherit imports; + nix.binaryCaches = [ "https://cache.nixos.org/" ]; +} diff --git a/profiles/cachix/nix-community.nix b/profiles/cachix/nix-community.nix new file mode 100644 index 00000000..7e4be286 --- /dev/null +++ b/profiles/cachix/nix-community.nix @@ -0,0 +1,10 @@ +{ + nix = { + binaryCaches = [ + "https://nix-community.cachix.org" + ]; + binaryCachePublicKeys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; +} diff --git a/profiles/cachix/nrdxp.nix b/profiles/cachix/nrdxp.nix new file mode 100644 index 00000000..bb3b4a59 --- /dev/null +++ b/profiles/cachix/nrdxp.nix @@ -0,0 +1,10 @@ +{ + nix = { + binaryCaches = [ + "https://nrdxp.cachix.org" + ]; + binaryCachePublicKeys = [ + "nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4=" + ]; + }; +} diff --git a/profiles/core/default.nix b/profiles/core/default.nix new file mode 100644 index 00000000..d2801d89 --- /dev/null +++ b/profiles/core/default.nix @@ -0,0 +1,154 @@ +{ self, config, lib, pkgs, ... }: +let inherit (lib) fileContents; +in +{ + imports = [ ../cachix ]; + + nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + + environment = { + + systemPackages = with pkgs; [ + binutils + coreutils + curl + direnv + dnsutils + dosfstools + fd + git + bottom + gptfdisk + iputils + jq + manix + moreutils + nix-index + nmap + ripgrep + skim + tealdeer + usbutils + utillinux + whois + ]; + + shellInit = '' + export STARSHIP_CONFIG=${ + pkgs.writeText "starship.toml" + (fileContents ./starship.toml) + } + ''; + + shellAliases = + let ifSudo = lib.mkIf config.security.sudo.enable; + in + { + # quick cd + ".." = "cd .."; + "..." = "cd ../.."; + "...." = "cd ../../.."; + "....." = "cd ../../../.."; + + # git + g = "git"; + + # grep + grep = "rg"; + gi = "grep -i"; + + # internet ip + myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; + + # nix + n = "nix"; + np = "n profile"; + ni = "np install"; + nr = "np remove"; + ns = "n search --no-update-lock-file"; + nf = "n flake"; + nepl = "n repl ''"; + srch = "ns nixos"; + orch = "ns override"; + nrb = ifSudo "sudo nixos-rebuild"; + mn = '' + manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix + ''; + + # fix nixos-option + nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; + + # sudo + s = ifSudo "sudo -E "; + si = ifSudo "sudo -i"; + se = ifSudo "sudoedit"; + + # top + top = "btm"; + + # systemd + ctl = "systemctl"; + stl = ifSudo "s systemctl"; + utl = "systemctl --user"; + ut = "systemctl --user start"; + un = "systemctl --user stop"; + up = ifSudo "s systemctl start"; + dn = ifSudo "s systemctl stop"; + jtl = "journalctl"; + + }; + }; + + fonts = { + fonts = with pkgs; [ powerline-fonts dejavu_fonts ]; + + fontconfig.defaultFonts = { + + monospace = [ "DejaVu Sans Mono for Powerline" ]; + + sansSerif = [ "DejaVu Sans" ]; + + }; + }; + + nix = { + + autoOptimiseStore = true; + + gc.automatic = true; + + optimise.automatic = true; + + useSandbox = true; + + allowedUsers = [ "@wheel" ]; + + trustedUsers = [ "root" "@wheel" ]; + + extraOptions = '' + min-free = 536870912 + keep-outputs = true + keep-derivations = true + fallback = true + ''; + + }; + + programs.bash = { + promptInit = '' + eval "$(${pkgs.starship}/bin/starship init bash)" + ''; + interactiveShellInit = '' + eval "$(${pkgs.direnv}/bin/direnv hook bash)" + ''; + }; + + # For rage encryption, all hosts need a ssh key pair + services.openssh = { + enable = true; + openFirewall = lib.mkDefault false; + }; + + services.earlyoom.enable = true; + +} diff --git a/profiles/core/starship.toml b/profiles/core/starship.toml new file mode 100644 index 00000000..6ed366b5 --- /dev/null +++ b/profiles/core/starship.toml @@ -0,0 +1,95 @@ +[aws] +symbol = "๎Œฝ " + +[character] +success_symbol = "[โฏ](bold purple)" +vicmd_symbol = "[โฎ](bold purple)" + +[battery] +full_symbol = "๏•ธ" +charging_symbol = "๏–ƒ" +discharging_symbol = "๏–‚" + +[conda] +symbol = "๏„Œ " + +[directory] +style = "cyan" +read_only = " ๐Ÿ”’" + +[docker] +symbol = "๏Œˆ " + +[elixir] +symbol = "๎‰ต " + +[elm] +symbol = "๎˜ฌ " + +[git_branch] +format = "[$symbol$branch]($style) " +symbol = "๏˜ " +style = "bold dimmed white" + +[git_status] +format = '([ใ€Œ$all_status$ahead_behindใ€]($style) )' +conflicted = "โš ๏ธ" +ahead = "โŸซ${count} " +behind = "โŸช${count}" +diverged = "๐Ÿ”€ " +untracked = "๐Ÿ“ " +stashed = "โ†ช " +modified = "๐šซ " +staged = "โœ” " +renamed = "โ‡† " +deleted = "โœ˜ " +style = "bold bright-white" + +[golang] +symbol = "๎˜ง " + +[haskell] +symbol = "๎˜Ÿ " + +[hg_branch] +symbol = "๏˜ " + +[java] +symbol = "๎‰– " + +[julia] +symbol = "๎˜ค " + +[memory_usage] +symbol = "๏กš " +disabled = false + +[nim] +symbol = "๏šค " + +[nix_shell] +format = '[$symbol$state]($style) ' +symbol = "๏‹œ " +pure_msg = "ฮป" +impure_msg = "โŽ”" + +[nodejs] +symbol = "๎‰ " + +[package] +symbol = "๏ฃ– " + +[php] +symbol = "๎˜ˆ " + +[python] +symbol = "๎˜† " + +[ruby] +symbol = "๎ˆพ " + +[rust] +symbol = "๏€“ " + +[status] +disabled = false diff --git a/pull-nix-files-and-push.sh b/pull-nix-files-and-push.sh deleted file mode 100755 index 10b6c0ed..00000000 --- a/pull-nix-files-and-push.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -cp /etc/nixos/* ./ -git add . -git commit -m "updated" -git push diff --git a/reference/cozette.nix b/reference/cozette.nix deleted file mode 100644 index 8546f743..00000000 --- a/reference/cozette.nix +++ /dev/null @@ -1,11 +0,0 @@ -# this may not work?? - -{pkgs, ...}: { - fonts.fonts = [ "${pkgs.fetchFromGitHub { - owner = "slavfox"; - repo = "cozette"; - rev = "5c101c91bf2ed0039aad02f9bf76ddb2018b1f21"; #not right - sha256 = "0s119zln3yrhhscfwkjncj72cr68694643009aam63s2ng4hsmfl"; #not right either - }}/bitmap" ]; #something should be changed here too - fonts.fontconfig.allowBitmaps = true; -} diff --git a/reference/networking.nix b/reference/networking.nix deleted file mode 100644 index 6ed28803..00000000 --- a/reference/networking.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, ... }: -{ - networking.interfaces.enp3s0.ipv4.addresses = [ { - address = "192.168.1.6"; - prefixLength = 24; - } ]; - networking.nameservers = [ "1.1.1.1" ]; - networking.defaultGateway = "192.168.1.1"; - environment.systemPackages = [ pkgs.mosh ]; - programs.mosh.enable = true; - #config.nssDatabase.hosts = [ "mdns_minimal" "[NOTFOUND=return]" ]; -} diff --git a/reference/shaarli-broken.nix b/reference/shaarli-broken.nix deleted file mode 100644 index 1541149c..00000000 --- a/reference/shaarli-broken.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ config, pkgs, ... }: -let - app = "shaarli"; - dataDir = "/var/www/${app}"; -in { - services.nginx = { - enable = true; - virtualHosts = { - "192.168.1.6:1232" = { - forceSSL = false; - enableACME = false; - #root = pkgs.shaarli; - root = dataDir; - listen = [ { addr = "192.168.1.6"; port = 1232; } ]; - extraConfig = '' - index index.php; - ''; - locations = { - "/".index = "index.php"; - - "~ /\\.".extraConfig = '' - log_not_found off; - deny all; - ''; - - "~ (index)\\.php$".extraConfig = '' - try_files $uri =404 - include ${pkgs.nginx}/conf/fastcgi.conf; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SHAARLI_CONFIG /var/www/shaarli/config; - - fastcgi_pass unix:${config.services.phpfpm.pools.${app}.socket}; - fastcgi_index index.php; - ''; - - "^~ /tpl/".extraConfig = "alias ${pkgs.shaarli}/tpl/;"; - - "~ \\.php$".extraConfig = '' - deny all; - ''; - - "^~ /plugins/".extraConfig = "alias ${pkgs.shaarli}/plugins/;"; - - "~* \\.(?:ico|css|js|gif|jpe?g|png)$".extraConfig = '' - expires max; - add_header Pragma public; - add_header Cache-Control "public, must-revalidate, proxy-revalidate"; - ''; - }; - }; - }; - }; - services.phpfpm.pools.${app} = { - user = app; - #listen = "/run/phpfpm/shaarli.sock"; - settings = { - "listen.owner" = config.services.nginx.user; - "pm" = "dynamic"; - "pm.max_children" = 4; - "pm.start_servers" = 2; - "pm.min_spare_servers" = 1; - "pm.max_spare_servers" = 4; - "pm.max_requests" = 32; - "php_admin_value[error_log]" = "stderr"; - "php_admin_flag[log_errors]" = true; - }; - }; - systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ]; - users.users.${app} = { - isSystemUser = true; - createHome = true; - home = dataDir; - group = app; - }; - users.groups.${app} = {}; - networking.firewall.allowedTCPPorts = [ 1232 ]; -} diff --git a/reference/shaarli-docker.nix b/reference/shaarli-docker.nix deleted file mode 100644 index f2193fcf..00000000 --- a/reference/shaarli-docker.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkg, config, lib, ... }: -{ - docker-containers."shaarli" = { - image = "shaarli/shaarli"; - volumes = [ "shaarli:/var/lib/shaarli/data/" ]; - ports = [ "1233:80" ]; - }; - networking.firewall.allowedTCPPorts = [ 1233 ]; -} diff --git a/reference/shaarli-tokudan.nix b/reference/shaarli-tokudan.nix deleted file mode 100644 index 8a3c3fca..00000000 --- a/reference/shaarli-tokudan.nix +++ /dev/null @@ -1,97 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - phppoolName = "shaarli"; - dataDir = "/var/lib/shaarli"; - vhost = "192.168.1.6:1232"; - - shaarli = pkgs.callPackage ./pkg-shaarli.nix { - inherit dataDir; - }; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "${dataDir}"; - listen = [ { addr = "192.168.1.6"; port = 1232; } ]; - extraConfig = '' - index index.php; - ''; - locations."/" = { - extraConfig = '' - try_files _ /index.php$is_args$args;"; - ''; - }; - locations."~ (index)\\.php$" = { - extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - fastcgi_pass unix:${config.services.phpfpm.pools.shaarli.socket}; - fastcgi_index index.php; - - fastcgi_param QUERY_STRING $query_string; - fastcgi_param REQUEST_METHOD $request_method; - fastcgi_param CONTENT_TYPE $content_type; - fastcgi_param CONTENT_LENGTH $content_length; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_param DOCUMENT_URI $document_uri; - fastcgi_param DOCUMENT_ROOT $document_root; - fastcgi_param SERVER_PROTOCOL $server_protocol; - - fastcgi_param GATEWAY_INTERFACE CGI/1.1; - fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; - - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REMOTE_PORT $remote_port; - fastcgi_param SERVER_ADDR $server_addr; - fastcgi_param SERVER_PORT $server_port; - fastcgi_param SERVER_NAME $server_name; - - fastcgi_param HTTPS $https; - ''; - }; - }; - services.phpfpm.pools.shaarli = { - user = "shaarli"; - group = "shaarli"; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "shaarli"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - }; - }; - users.extraUsers.shaarli = { group = "shaarli"; home = dataDir; }; - users.extraGroups.shaarli = { }; - systemd.services.shaarli-install = { - serviceConfig.Type = "oneshot"; - wantedBy = [ "multi-user.target" ]; - script = '' - if [ ! -d "${dataDir}" ]; then - mkdir -p ${dataDir}/{cache,data,pagecache,tmp} - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/cache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/data/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ - cp -R ${shaarli}/data.orig/.htaccess ${dataDir}/tmp/ - fi - chown -Rc shaarli:shaarli ${dataDir} - find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; - find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; - ''; - }; - networking.firewall.allowedTCPPorts = [ 1232 ]; -} diff --git a/reference/shiori.nix b/reference/shiori.nix deleted file mode 100644 index a1dfde45..00000000 --- a/reference/shiori.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, config, lib, ... }: -{ - services.shiori.enable = true; - services.shiori.address = "192.168.1.6"; - services.shiori.port = 1234; - networking.firewall.allowedTCPPorts = [ 1234 ]; -} diff --git a/reference/test-nginx.nix b/reference/test-nginx.nix deleted file mode 100644 index 69c480f2..00000000 --- a/reference/test-nginx.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - vhost = "192.168.1.6:1232"; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "/var/lib/test"; - listen = [ { addr = "192.168.1.6"; port = 1232; } ]; - extraConfig = '' - index index.html; - ''; - - locations."/" = { - extraConfig = '' - try_files $uri $uri/ index.html; - ''; - }; - }; - - networking.firewall.allowedTCPPorts = [ 1232 ]; -} diff --git a/reference/wallabag-docker.nix b/reference/wallabag-docker.nix deleted file mode 100644 index 4bd844a1..00000000 --- a/reference/wallabag-docker.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ pkg, config, lib, ... }: -{ - docker-containers."wallabag-db" = { - image = "postgres"; - environment = { - "POSTGRES_PASSWORD" = "wallaroot"; - "POSTGRES_USER" = "postgres"; - }; - extraDockerOptions = [ "--network=wallabag-br" ]; - volumes = [ "/opt/wallabag/data:/var/www/wallabag" ]; - }; - - docker-containers."wallabag" = { - image = "wallabag/wallabag"; - ports = [ "800:80" ]; - #volumes = [ "/opt/wallabag/data:/var/www/wallabag/data" "/opt/wallabag/images:/var/www/wallabag/web/assets/images" ]; - environment = { - "SYMFONY__ENV__DOMAIN_NAME" = "http://192.168.1.6:800"; - "POSTGRES_PASSWORD" = "wallaroot"; - "POSTGRES_USER" = "postgres"; - "SYMFONY__ENV__DATABASE_DRIVER" = "pdo_pgsql"; - "SYMFONY__ENV__DATABASE_DRIVER_CLASS" = "Wallabag\\CoreBundle\\Doctrine\\DBAL\\Driver\\CustomPostgreSQLDriver"; - "SYMFONY__ENV__DATABASE_HOST" = "wallabag-db"; - "SYMFONY__ENV__DATABASE_PORT" = "5432"; - "SYMFONY__ENV__DATABASE_NAME" = "wallabag"; - "SYMFONY__ENV__DATABASE_USER" = "wallabag"; - "SYMFONY__ENV__DATABASE_PASSWORD" = "wallapass"; - #"SYMFONY__ENV__DATABASE_CHARSET" = "utf8mb4"; - }; - extraDockerOptions = [ "--network=wallabag-br" ]; - }; - - systemd.services.init-wallabag-docker-br = { - description = "Create the network bridge wallabag."; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - - serviceConfig.Type = "oneshot"; - script = let dockercli = "${config.virtualisation.docker.package}/bin/docker"; - in '' - # Put a true at the end to prevent getting non-zero return code, which will - # crash the whole service. - check=$(${dockercli} network ls | grep "wallabag-br" || true) - if [ -z "$check" ]; then - ${dockercli} network create wallabag-br - else - echo "wallabag-br already exists in docker" - fi - ''; - }; - networking.firewall.allowedTCPPorts = [ 800 ]; -} diff --git a/reference/wallabag.nix b/reference/wallabag.nix deleted file mode 100644 index d0e26f92..00000000 --- a/reference/wallabag.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - phppoolName = "wallabag"; - dataDir = "/var/lib/wallabag"; - vhost = "read.mossnet.local"; -in -{ - services.nginx.virtualHosts."${vhost}" = { - forceSSL = false; - enableACME = false; - root = "/var/lib/wallabag/web"; - listen = [ { addr = "192.168.1.6"; port = 800; } ]; - - locations."/" = { - extraConfig = '' - try_files $uri /app.php$is_args$args; - ''; - }; - - locations."/assets".root = "${dataDir}/web"; - - locations."~ ^/app\.php(/|$)" = { - extraConfig = '' - include ${pkgs.nginx}/conf/fastcgi_params; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } - - fastcgi_pass unix:${config.services.phpfpm.pools."${phppoolName}".socket}; - fastcgi_param SCRIPT_FILENAME {pkgs.wallabag}/web/$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT {pkgs.wallabag}/web; - ''; - }; - - locations."~ \.php$" = { - extraConfig = '' - return 404; - ''; - }; - }; - services.postgresql = { - enable = true; - - # Ensure the database, user, and permissions always exist - ensureDatabases = [ "wallabag" ]; - ensureUsers = [ - { name = "wallabag"; - ensurePermissions."DATABASE wallabag" = "ALL PRIVILEGES"; - } - ]; - }; - services.phpfpm.pools."${phppoolName}" = { - user = "wallabag"; - group = "wallabag"; - phpEnv."WALLABAG_DATA" = "/var/lib/wallabag"; - phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; - settings = { - "listen.owner" = "nginx"; - "listen.group" = "nginx"; - "user" = "wallabag"; - "pm" = "dynamic"; - "pm.max_children" = "75"; - "pm.min_spare_servers" = "5"; - "pm.max_spare_servers" = "20"; - "pm.max_requests" = "10"; - "catch_workers_output" = "1"; - }; - }; - - systemd.services.wallabag-install = { - description = "Wallabag install service"; - wantedBy = [ "multi-user.target" ]; - before = [ "phpfpm-wallabag.service" ]; - after = [ "mysql.service" "postgresql.service" ]; - path = [ pkgs.coreutils pkgs.php73 pkgs.php73Packages.composer ]; - - serviceConfig = { - User = "wallabag"; - Type = "oneshot"; - RemainAfterExit = "yes"; - PermissionsStartOnly = true; - }; - - preStart = '' - mkdir -p "${dataDir}" - chown wallabag:nginx "${dataDir}" - ''; - - script = '' - echo "Setting up wallabag files in ${dataDir} ..." - cd "${dataDir}" - - rm -rf var/cache/* - rm -f ${dataDir}/app - rm -f ${dataDir}/bin - ln -sf ${pkgs.wallabag}/app app - ln -sf ${pkgs.wallabag}/composer.{json,lock} . - ln -sf ${pkgs.wallabag}/bin/ bin - - export WALLABAG_DATA="${dataDir}" - if [ ! -f installed ]; then - php /var/lib/wallabag/bin/console --env=prod doctrine:database:create --if-not-exists --no-interaction - php /var/lib/wallabag/bin/console --env=prod doctrine:migrations:migrate --no-interaction - # Until https://github.com/wallabag/wallabag/issues/3662 is fixed - yes no | php /var/lib/wallabag/bin/console --env=prod wallabag:install - touch installed - else - php ${pkgs.wallabag}/bin/console --env=prod doctrine:migrations:migrate --no-interaction - fi - php ${pkgs.wallabag}/bin/console --env=prod cache:clear - ''; - }; - - users.extraUsers.wallabag = { group = "wallabag"; }; - users.extraGroups.wallabag = { }; - - networking.firewall.allowedTCPPorts = [ 800 ]; -} diff --git a/secrets/.gitattributes b/secrets/.gitattributes new file mode 100644 index 00000000..901863e3 --- /dev/null +++ b/secrets/.gitattributes @@ -0,0 +1,4 @@ +* filter=git-crypt diff=git-crypt +.gitattributes !filter !diff +secrets.nix !filter !diff +README.md !filter !diff diff --git a/secrets/secrets.nix b/secrets/secrets.nix new file mode 100644 index 00000000..bac30e03 --- /dev/null +++ b/secrets/secrets.nix @@ -0,0 +1,9 @@ +let + # set ssh public keys here for your system and user + system = ""; + user = ""; + allKeys = [ system user ]; +in +{ + "secret.age".publicKeys = allKeys; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..575a5d82 --- /dev/null +++ b/shell.nix @@ -0,0 +1 @@ +(import ./lib/compat).shellNix diff --git a/shell/default.nix b/shell/default.nix new file mode 100644 index 00000000..aef90a55 --- /dev/null +++ b/shell/default.nix @@ -0,0 +1,10 @@ +{ self, inputs, ... }: +{ + externalModules = with inputs; [ + bud.devshellModules.bud + ]; + modules = [ + ./devos.nix + ]; +} + diff --git a/shell/devos.nix b/shell/devos.nix new file mode 100644 index 00000000..128b45c3 --- /dev/null +++ b/shell/devos.nix @@ -0,0 +1,61 @@ +{ pkgs, extraModulesPath, ... }: +let + + hooks = import ./hooks; + + pkgWithCategory = category: package: { inherit package category; }; + linter = pkgWithCategory "linter"; + docs = pkgWithCategory "docs"; + devos = pkgWithCategory "devos"; + +in +{ + _file = toString ./.; + + imports = [ "${extraModulesPath}/git/hooks.nix" ]; + git = { inherit hooks; }; + + # tempfix: remove when merged https://github.com/numtide/devshell/pull/123 + devshell.startup.load_profiles = pkgs.lib.mkForce (pkgs.lib.noDepEntry '' + # PATH is devshell's exorbitant privilige: + # fence against its pollution + _PATH=''${PATH} + # Load installed profiles + for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do + # If that folder doesn't exist, bash loves to return the whole glob + [[ -f "$file" ]] && source "$file" + done + # Exert exorbitant privilige and leave no trace + export PATH=''${_PATH} + unset _PATH + ''); + + packages = with pkgs; [ + git-crypt + ]; + + commands = with pkgs; [ + (devos nixUnstable) + (devos agenix) + { + category = "devos"; + name = pkgs.nvfetcher-bin.pname; + help = pkgs.nvfetcher-bin.meta.description; + command = "cd $DEVSHELL_ROOT/pkgs; ${pkgs.nvfetcher-bin}/bin/nvfetcher -c ./sources.toml --no-output $@"; + } + (linter nixpkgs-fmt) + (linter editorconfig-checker) + # (docs python3Packages.grip) too many deps + (docs mdbook) + ] + + ++ lib.optional + (pkgs ? deploy-rs) + (devos deploy-rs.deploy-rs) + + ++ lib.optional + (system != "i686-linux") + (devos cachix) + + ; +} diff --git a/shell/hooks/default.nix b/shell/hooks/default.nix new file mode 100644 index 00000000..10f2c9d2 --- /dev/null +++ b/shell/hooks/default.nix @@ -0,0 +1,4 @@ +{ + enable = true; + pre-commit.text = builtins.readFile ./pre-commit.sh; +} diff --git a/shell/hooks/pre-commit.sh b/shell/hooks/pre-commit.sh new file mode 100755 index 00000000..985d3b40 --- /dev/null +++ b/shell/hooks/pre-commit.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(${git}/bin/git hash-object -t tree /dev/null) +fi + +diff="git diff-index --name-only --cached $against --diff-filter d" + +nix_files=($($diff -- '*.nix')) +all_files=($($diff)) + +# Format staged nix files. +if [[ -n "${nix_files[@]}" ]]; then + nixpkgs-fmt "${nix_files[@]}" \ + && git add "${nix_files[@]}" +fi + +# check editorconfig +editorconfig-checker -- "${all_files[@]}" +if [[ $? != '0' ]]; then + printf "%b\n" \ + "\nCode is not aligned with .editorconfig" \ + "Review the output and commit your fixes" >&2 + exit 1 +fi diff --git a/bowl/taskd.nix.save b/users/modules/.flake-keep similarity index 100% rename from bowl/taskd.nix.save rename to users/modules/.flake-keep diff --git a/users/nixos/default.nix b/users/nixos/default.nix new file mode 100644 index 00000000..5c037fe8 --- /dev/null +++ b/users/nixos/default.nix @@ -0,0 +1,12 @@ +{ hmUsers, ... }: +{ + home-manager.users = { inherit (hmUsers) nixos; }; + + users.users.nixos = { + uid = 1000; + password = "nixos"; + description = "default"; + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; +} diff --git a/users/profiles/direnv/default.nix b/users/profiles/direnv/default.nix new file mode 100644 index 00000000..d345e2d3 --- /dev/null +++ b/users/profiles/direnv/default.nix @@ -0,0 +1,9 @@ +{ + programs.direnv = { + enable = true; + nix-direnv = { + enable = true; + enableFlakes = true; + }; + }; +} diff --git a/users/profiles/git/default.nix b/users/profiles/git/default.nix new file mode 100644 index 00000000..4c9637e5 --- /dev/null +++ b/users/profiles/git/default.nix @@ -0,0 +1,45 @@ +{ + programs.git = { + enable = true; + + extraConfig = { + pull.rebase = false; + }; + + aliases = { + a = "add -p"; + co = "checkout"; + cob = "checkout -b"; + f = "fetch -p"; + c = "commit"; + p = "push"; + ba = "branch -a"; + bd = "branch -d"; + bD = "branch -D"; + d = "diff"; + dc = "diff --cached"; + ds = "diff --staged"; + r = "restore"; + rs = "restore --staged"; + st = "status -sb"; + + # reset + soft = "reset --soft"; + hard = "reset --hard"; + s1ft = "soft HEAD~1"; + h1rd = "hard HEAD~1"; + + # logging + lg = + "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"; + plog = + "log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'"; + tlog = + "log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative"; + rank = "shortlog -sn --no-merges"; + + # delete merged branches + bdm = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"; + }; + }; +} diff --git a/users/root/default.nix b/users/root/default.nix new file mode 100644 index 00000000..f38c7391 --- /dev/null +++ b/users/root/default.nix @@ -0,0 +1,5 @@ +{ ... }: +# recommend using `hashedPassword` +{ + users.users.root.password = ""; +}