diff --git a/.drone.yml b/.drone.yml index b4d4bb92..23805095 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,72 +1,79 @@ ---- -kind: pipeline -type: exec -name: Check -node: - hosttype: baremetal - -steps: - - name: "Check" - when: - event: - - pull_request - environment: - NIX_FLAGS: "--print-build-logs --verbose" - commands: - - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' - - nix $$NIX_FLAGS develop --command nix flake show - - nix $$NIX_FLAGS build ".#nixosConfigurations.PubSolarOS.config.system.build.toplevel" - ---- -kind: pipeline -type: exec -name: Tests -node: - hosttype: baremetal - -steps: - - name: "Tests" - environment: - NIX_FLAGS: "--print-build-logs --verbose" - commands: - - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' - - nix $$NIX_FLAGS build ".#checks.x86_64-linux.customTestFor-PubSolarOS-firstTest" - - nix-store --read-log result - - nix $$NIX_FLAGS flake check - - nix $$NIX_FLAGS develop --command echo OK - - - name: "Upload artifacts" - environment: - TRITON_DONT_SOURCE_PROFILE: 1 - PRIVATE_SSH_KEY: - from_secret: private_ssh_key - MANTA_USER: pub_solar - MANTA_URL: https://eu-central.manta.greenbaum.cloud - MANTA_KEY_ID: "5d:5f:3d:22:8d:37:1f:e6:d6:ab:06:18:d9:a2:04:67" - commands: - - export TARGET_DIR="ci/$${DRONE_REPO}/$${DRONE_BUILD_NUMBER}" - - echo env var TARGET_DIR is set to $$TARGET_DIR - - "mkdir ~/.ssh && chmod 700 ~/.ssh" - - echo "$$PRIVATE_SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519 - - nix flake new --template "git+https://git.greenbaum.cloud/dev/tritonshell?ref=main" ./tritonshell - - git add tritonshell - - cd tritonshell - - nix develop --command mput -p -f ../result/foot_wayland_info.png ~~/public/$${TARGET_DIR}/foot_wayland_info.png - - nix develop --command mput -p -f ../result/test-wayland.out ~~/public/$${TARGET_DIR}/test-wayland.out - -trigger: - ref: - - refs/tags/v* - - refs/tags/t* - --- kind: pipeline type: docker -name: Notification +name: Upstreaming steps: + - name: "Sync 'devos' branch with upstream" + image: alpine/git + when: + event: + - cron + cron: + - sync-main-with-upstream + environment: + GITEA_SSH_KEY: + from_secret: gitea_ssh_key + commands: + - ./.drone/setup_ssh.sh + - git remote add devos git@git.b12f.io:pub-solar/devos + - git remote set-url origin git@git.b12f.io:pub-solar/os + - git fetch --all + - git checkout -b devos --track origin/devos + - git merge -X theirs devos/main + - git push origin devos + - git remote set-url origin https://git.b12f.io/pub-solar/os.git + + - name: "Sync $BRANCH with upstream" + image: alpine/git + when: + event: + - cron + cron: + - sync-main-with-upstream + - sync-b12f-with-main + - sync-teutat3s-with-main + environment: + GITEA_SSH_KEY: + from_secret: gitea_ssh_key + commands: + - git fetch origin + - git checkout origin/main + - ./.drone/setup_ssh.sh + - git remote set-url origin git@git.b12f.io:pub-solar/os + - git fetch --all + - ./.drone/upstream-branch.sh + + - name: "Open pull request for failed merge" + image: nixery.dev/shell/tea + when: + status: + - failure + event: + - cron + cron: + - sync-main-with-upstream + - sync-b12f-with-main + - sync-teutat3s-with-main + environment: + TEA_CONFIG: + from_secret: tea_config + commands: + - mkdir -p ~/.config/tea + - echo "$$TEA_CONFIG" > ~/.config/tea/config.yml + - tea pulls create --base main --head devos + - name: "Notify matrix" image: plugins/matrix + when: + status: + - failure + event: + - cron + cron: + - sync-main-with-upstream + - sync-b12f-with-main + - sync-teutat3s-with-main settings: homeserver: https://matrix.pub.solar roomid: dfQBqwkhIzrFjMSsxy:pub.solar @@ -74,15 +81,32 @@ steps: from_secret: matrix_username password: from_secret: matrix_password - template: "Test run triggered by tag: {{ build.tag }}. Test run exit status: {{ build.status }}. Artifacts uploaded to Manta: https://eu-central.manta.greenbaum.cloud/pub_solar/public/ci/{{ repo.Owner }}/{{ repo.Name }}/{{ build.number }}/foot_wayland_info.png" - -depends_on: - - Tests + template: "Upstreaming {{ build.status }} [{{ build.branch }}#{{ truncate build.commit 8 }}]({{ build.link }}) by {{ build.author }}. [Pull requests](https://git.b12f.io/pub-solar/os/pulls)" trigger: - ref: - - refs/tags/v* - - refs/tags/t* + event: + - cron + +--- +kind: pipeline +type: docker +name: Check + +steps: + - name: "Check" + image: docker.nix-community.org/nixpkgs/nix-flakes:latest + when: + event: + - pull_request + - tag + environment: + NIX_FLAGS: "--print-build-logs --verbose" + commands: + - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' + - nix $$NIX_FLAGS flake check + - nix $$NIX_FLAGS build ".#nixosConfigurations.PubSolarOS.config.system.build.toplevel" + - nix $$NIX_FLAGS develop --command echo OK + - nix $$NIX_FLAGS develop --command bud --help --- kind: pipeline @@ -92,55 +116,41 @@ name: Publish ISO steps: - name: "Build ISO" image: docker.nix-community.org/nixpkgs/nix-flakes:latest - environment: - NIX_FLAGS: "--print-build-logs --verbose" volumes: - name: file-exchange path: /var/nix/iso-cache commands: - | - nix $$NIX_FLAGS build \ - '.#nixosConfigurations.bootstrap.config.system.build.isoImage' - - cp $(readlink -f result)/iso/PubSolarOS*.iso /var/nix/iso-cache/ - - nix shell nixpkgs#findutils - - cd /var/nix/iso-cache/ - - export ISO_NAME=$(find . -name '*.iso' -printf "%f\n") - - sha256sum $ISO_NAME > $ISO_NAME.sha256 - - ln -s $ISO_NAME PubSolarOS-latest.iso - - cp $ISO_NAME.sha256 PubSolarOS-latest.iso.sha256 - - nix run nixpkgs#gnused -- --in-place "s/$ISO_NAME/PubSolarOS-latest.iso/" PubSolarOS-latest.iso.sha256 + nix --print-build-logs --verbose \ + develop --command \ + bud build bootstrap bootstrapIso + - cp $(readlink -f result)/iso/*.iso /var/nix/iso-cache/ - name: "Publish ISO" - # custom drone-scp image, source: https://git.b12f.io/pub-solar/drone-scp/ - # docker build --tag registry.greenbaum.cloud/library/drone-scp:v1.6.5 --file ./docker/Dockerfile.linux.amd64 . - image: registry.greenbaum.cloud/library/drone-scp:v1.6.5 + image: appleboy/drone-scp volumes: - name: file-exchange path: /var/nix/iso-cache settings: host: - from_secret: iso_web_ssh_host + from_secret: ssh_host user: - from_secret: iso_web_ssh_user + from_secret: ssh_user port: - from_secret: iso_web_ssh_port + from_secret: ssh_port key: - from_secret: iso_web_ssh_key - target: /srv/os/download + from_secret: ssh_key + target: /srv/os source: - /var/nix/iso-cache/*.iso - - /var/nix/iso-cache/*.iso.sha256 - unlink_first: true strip_components: 3 depends_on: - Check trigger: - branch: - - main event: - - push + - tag volumes: - name: file-exchange @@ -148,6 +158,6 @@ volumes: --- kind: signature -hmac: 291be33bbf2954d1f5e4bf569679e24a773e7d6f90db4765fb9dacb3686a825e +hmac: bdbefb07b97dc8efc44d8eb36ee4d1bb89eec3b7255b49929e126e86a4b4a788 ... diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index e3af7e20..86f5dd70 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -1,13 +1,18 @@ -# TL;DR; +# Pull Requests + +## TL;DR; - **Target Branch**: `main` -- **Merge Policy**: green check: merge away. yellow circle: have patience. red x: try again. -- **Docs**: every change set is expected to contain doc updates +- **Merge Policy**: [`bors`][bors] is always 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 you can - make use of the `./examples` & `./e2e` and wire test up in the devshell. +- **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 `check-all` from within the devshell on your local machine +- **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 index 09d2d626..1d7bafe9 100644 --- a/doc/SUMMARY.md +++ b/doc/SUMMARY.md @@ -3,6 +3,8 @@ - [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) @@ -16,16 +18,11 @@ - [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) -- [API Reference](./api-reference.md) - - [Channels](./api-reference-channels.md) - - [Home](./api-reference-home.md) - - [Devshell](./api-reference-devshell.md) - - [NixOS](./api-reference-nixos.md) -- [Library Reference]() - [Contributing](./CONTRIBUTING.md) - diff --git a/doc/api-reference-channels.md b/doc/api-reference-channels.md deleted file mode 100755 index 533e6e91..00000000 --- a/doc/api-reference-channels.md +++ /dev/null @@ -1,91 +0,0 @@ -# Channels API Container -Configure your channels that you can use throughout your configurations. - -> #### ⚠ Gotcha ⚠ -> Devshell & (non-host-specific) Home-Manager `pkgs` instances are rendered off the -> `nixos.hostDefaults.channelName` (default) channel. - - -## channels -nixpkgs channels to create - - -*_Type_*: -attribute set of submodules or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## channels.\.config -nixpkgs config for this channel - - -*_Type_*: -attribute set or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## channels.\.input -nixpkgs flake input to use for this channel - - -*_Type_*: -nix flake - - -*_Default_* -``` -"self.inputs." -``` - - - - -## channels.\.overlays -overlays to apply to this channel -these will get exported under the 'overlays' flake output -as \/\ and any overlay pulled from \ -will be filtered out - - -*_Type_*: -list of valid Nixpkgs overlay or path convertible to its or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## channels.\.patches -patches to apply to this channel - - -*_Type_*: -list of paths - - -*_Default_* -``` -[] -``` - - - - diff --git a/doc/api-reference-devshell.md b/doc/api-reference-devshell.md deleted file mode 100755 index 28f18087..00000000 --- a/doc/api-reference-devshell.md +++ /dev/null @@ -1,72 +0,0 @@ -# Devshell API Container -Configure your devshell module collections of your environment. - - -## devshell -Modules to include in your DevOS shell. the `modules` argument -will be exported under the `devshellModules` output - - -*_Type_*: -submodule or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## devshell.exportedModules -modules to include in all hosts and export to devshellModules output - - -*_Type_*: -list of valid module or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## devshell.externalModules -The `externalModules` option has been removed. -Any modules that should be exported should be defined with the `exportedModules` -option and all other modules should just go into the `modules` option. - - -*_Type_*: -list of valid modules or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## devshell.modules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - diff --git a/doc/api-reference-home.md b/doc/api-reference-home.md deleted file mode 100755 index 0ab62f36..00000000 --- a/doc/api-reference-home.md +++ /dev/null @@ -1,119 +0,0 @@ -# Home-Manager API Container -Configure your home manager modules, profiles & suites. - - -## home -hosts, modules, suites, and profiles for home-manager - - -*_Type_*: -submodule or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## home.exportedModules -modules to include in all hosts and export to homeModules output - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## home.externalModules -The `externalModules` option has been removed. -Any modules that should be exported should be defined with the `exportedModules` -option and all other modules should just go into the `modules` option. - - -*_Type_*: -list of valid modules or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## home.importables -Packages of paths to be passed to modules as `specialArgs`. - - -*_Type_*: -attribute set - - -*_Default_* -``` -{} -``` - - - - -## home.importables.suites -collections of profiles - - -*_Type_*: -null or attribute set of list of paths or anything convertible to its or path convertible to it - - -*_Default_* -``` -null -``` - - - - -## home.modules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## home.users -HM users that can be deployed portably without a host. - - -*_Type_*: -attribute set of HM user configs - - -*_Default_* -``` -{} -``` - - - - diff --git a/doc/api-reference-nixos.md b/doc/api-reference-nixos.md deleted file mode 100755 index 7428b161..00000000 --- a/doc/api-reference-nixos.md +++ /dev/null @@ -1,234 +0,0 @@ -# NixOS API Container -Configure your nixos modules, profiles & suites. - - -## nixos -hosts, modules, suites, and profiles for NixOS - - -*_Type_*: -submodule or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## nixos.hostDefaults -Defaults for all hosts. -the modules passed under hostDefaults will be exported -to the 'nixosModules' flake output. -They will also be added to all hosts. - - -*_Type_*: -submodule - - -*_Default_* -``` -{} -``` - - - - -## nixos.hostDefaults.channelName -Channel this host should follow - - -*_Type_*: -channel defined in `channels` - - - - - - -## nixos.hostDefaults.exportedModules -modules to include in all hosts and export to nixosModules output - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hostDefaults.externalModules -The `externalModules` option has been removed. -Any modules that should be exported should be defined with the `exportedModules` -option and all other modules should just go into the `modules` option. - - -*_Type_*: -list of valid modules or anything convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hostDefaults.modules -modules to include that won't be exported -meant importing modules from external flakes - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hostDefaults.system -system for this host - - -*_Type_*: -null or system defined in `supportedSystems` - - -*_Default_* -``` -null -``` - - - - -## nixos.hosts -configurations to include in the nixosConfigurations output - - -*_Type_*: -attribute set of submodules - - -*_Default_* -``` -{} -``` - - - - -## nixos.hosts.\.channelName -Channel this host should follow - - -*_Type_*: -null or channel defined in `channels` - - -*_Default_* -``` -null -``` - - - - -## nixos.hosts.\.modules -modules to include - - -*_Type_*: -list of valid modules or anything convertible to it or path convertible to it - - -*_Default_* -``` -[] -``` - - - - -## nixos.hosts.\.system -system for this host - - -*_Type_*: -null or system defined in `supportedSystems` - - -*_Default_* -``` -null -``` - - - - -## nixos.hosts.\.tests -tests to run - - -*_Type_*: -list of valid NixOS test or path convertible to its or anything convertible to it - - -*_Default_* -``` -[] -``` - - -*_Example_* -``` -{"_type":"literalExpression","text":"[\n {\n name = \"testname1\";\n machine = { ... };\n testScript = ''\n # ...\n '';\n }\n ({ corutils, writers, ... }: {\n name = \"testname2\";\n machine = { ... };\n testScript = ''\n # ...\n '';\n })\n ./path/to/test.nix\n];\n"} -``` - - -## nixos.importables -Packages of paths to be passed to modules as `specialArgs`. - - -*_Type_*: -attribute set - - -*_Default_* -``` -{} -``` - - - - -## nixos.importables.suites -collections of profiles - - -*_Type_*: -null or attribute set of list of paths or anything convertible to its or path convertible to it - - -*_Default_* -``` -null -``` - - - - diff --git a/doc/api-reference.md b/doc/api-reference.md deleted file mode 100755 index 47eb1284..00000000 --- a/doc/api-reference.md +++ /dev/null @@ -1,80 +0,0 @@ -# Top Level API -`digga`'s top level API. API Containers are documented in their respective sub-chapter: - -- [Channels](./api-reference-channels.md) -- [Home](./api-reference-home.md) -- [Devshell](./api-reference-devshell.md) -- [NixOS](./api-reference-nixos.md) -- [Darwin](./api-reference-darwin.md) - -## channelsConfig -nixpkgs config for all channels - - -*_Type_*: -attribute set or path convertible to it - - -*_Default_* -``` -{} -``` - - - - -## inputs -The flake's inputs - -*_Type_*: -attribute set of nix flakes - - - - - - -## outputsBuilder -builder for flake system-spaced outputs -The builder gets passed an attrset of all channels - - -*_Type_*: -function that evaluates to a(n) attribute set or path convertible to it - - -*_Default_* -``` -"channels: { }" -``` - - - - -## self -The flake to create the DevOS outputs for - -*_Type_*: -nix flake - - - - - - -## supportedSystems -The systems supported by this flake - - -*_Type_*: -list of strings - - -*_Default_* -``` -["aarch64-linux","aarch64-darwin","i686-linux","x86_64-darwin","x86_64-linux"] -``` - - - - diff --git a/doc/book.toml b/doc/book.toml index f9dca6a3..373d26fd 100644 --- a/doc/book.toml +++ b/doc/book.toml @@ -3,4 +3,4 @@ authors = ["Timothy DeHerrera"] language = "en" multilingual = false src = "." -title = "PubSolarOS documentation" +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/users.md b/doc/concepts/users.md index b3454244..b2a6c2a3 100644 --- a/doc/concepts/users.md +++ b/doc/concepts/users.md @@ -49,18 +49,19 @@ argument that gets passed to your home-manager users. ## External Usage You can easily use the defined home-manager configurations outside of NixOS -using the `homeConfigurations` flake output. +using the `homeConfigurations` flake output. The [bud](../bud/index.md) helper +script makes this even easier. -This is great for keeping your environment consistent across Unix-like systems, -including macOS. +This is great for keeping your environment consistent across Unix systems, +including OSX. ### From within the projects devshell: ```sh -# builds the pub-solar user defined in the PubSolarOS host -nix build '.#homeConfigurations."pub-solar@PubSolarOS".activationPackage' +# builds the nixos user defined in the NixOS host +bud home NixOS nixos # build and activate -nix build '.#homeConfigurations."pub-solar@PubSolarOS".activationPackage' && ./result/activate && unlink result +bud home NixOS nixos switch ``` ### Manually from outside the project: diff --git a/doc/start/bootstrapping.md b/doc/start/bootstrapping.md new file mode 100644 index 00000000..b8a0ad04 --- /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 partition +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..3e8c84d6 --- /dev/null +++ b/doc/start/from-nixos.md @@ -0,0 +1,51 @@ +# 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 +bud 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 +bud 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`. + + diff --git a/doc/start/index.md b/doc/start/index.md index 9650ba05..2cd14d9a 100644 --- a/doc/start/index.md +++ b/doc/start/index.md @@ -2,35 +2,25 @@ The only dependency is nix, so make sure you have it [installed][install-nix]. ## Get the Template -If you currently don't have flakes setup, you can utilize the digga shell to pull the template: +Here is a snippet that will get you the template without the git history: ```sh -nix-shell "https://github.com/divnix/digga/archive/main.tar.gz" \ - --run "nix flake init -t github:divnix/digga" -``` -If you already have flakes support, you can directly pull the template: -```sh -nix flake init -t github:divnix/digga -``` +nix-shell -p cachix --run "cachix use nrdxp" + +nix-shell https://github.com/divnix/devos/archive/main.tar.gz -A shell \ + --run "bud get main" + +cd devos + +nix-shell -Then make sure to create the git repository: -```sh git init git add . git commit -m init ``` -To drop into a nix-shell, if you don't have flakes setup, use the digga shell to create a `flake.lock`: -```sh -nix-shell "https://github.com/divnix/digga/archive/main.tar.gz" \ - --run "nix flake lock" -``` -Or if you do have flakes support, just run: -```sh -nix flake lock -``` - -Finally, run `nix-shell` to get to an interactive shell with all the dependencies, including the unstable nix -version required. You can run `menu` to confirm that you are using digga (expected output includes [docs], [general commands], [linter], etc.). +This will place you in a new folder named `devos` 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. @@ -43,8 +33,9 @@ In addition, the [binary cache](../integrations/cachix.md) is added for faster d > 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 index b8fa6659..76af1c6e 100644 --- a/doc/start/iso.md +++ b/doc/start/iso.md @@ -1,36 +1,22 @@ -# Installation Media - -This project leverages [nix-community/nixos-generators][nixos-generators] for -building machine images. In most cases, you'll probably want to use the -`install-iso` format. - -Making an installable ISO for `hosts/bootstrap.nix` is as simple as: +# ISO +Making and writing an installable iso for `hosts/bootstrap.nix` is as simple as: ```sh -nix run github:nix-community/nixos-generators -- \ - --format install-iso \ - --flake '.#bootstrap' +bud build bootstrap bootstrapIso +sudo -E $(which bud) burn ``` -Then "burn" the ISO to your USB stick (or CD-R if you like!) following the -[instructions in the NixOS manual][burn] (or using your preferred USB burner). +This works for any host. -You can also swap out the `--format` for [any of the others][formats] supported -by nixos-generators. +## ISO image nix store & cache -Continue by following the usual installation instructions in the NixOS manual. +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. -## ISO Nix Store and Cache +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. -The ISO image holds the Nix store for the live environment and _also_ acts as a -binary cache to the installer. To considerably speed things up, the image -already includes all flake `inputs` as well as the `devshell` closures. +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. -While you _could_ provision any NixOS machine with the same USB stick, an ISO -custom-made for your target host will maximise 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. - -[nixos-generators]: https://github.com/nix-community/nixos-generators -[burn]: https://nixos.org/manual/nixos/stable/index.html#sec-booting-from-usb -[formats]: https://github.com/nix-community/nixos-generators/tree/master/formats diff --git a/flake.lock b/flake.lock index 060a2aea..2e4bdbcd 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1665870395, - "narHash": "sha256-Tsbqb27LDNxOoPLh0gw2hIb6L/6Ow/6lIBvqcHzEKBI=", + "lastModified": 1652712410, + "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=", "owner": "ryantm", "repo": "agenix", - "rev": "a630400067c6d03c9b3e0455347dc8559db14288", + "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b", "type": "github" }, "original": { @@ -20,6 +20,26 @@ "type": "github" } }, + "beautysh": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix" + }, + "locked": { + "lastModified": 1641830469, + "narHash": "sha256-uhDmgNP/biOWe4FtOa6c2xZnREH+NP9rdrMm0LccRUk=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "e85d9736927c0fcf2abb05cb3a2d8d9b4502a2eb", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, "blank": { "locked": { "lastModified": 1625557891, @@ -35,6 +55,31 @@ "type": "github" } }, + "bud": { + "inputs": { + "beautysh": "beautysh", + "devshell": [ + "digga", + "devshell" + ], + "nixpkgs": [ + "nixos" + ] + }, + "locked": { + "lastModified": 1654190822, + "narHash": "sha256-B8z3stYaULNDBBjzJHrFHGgiJHrLqhBkxH+9u5iBP7E=", + "owner": "divnix", + "repo": "bud", + "rev": "0ff3e4e4b8791ea4d827bf5bfcac28cef060f209", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "bud", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -42,11 +87,11 @@ ] }, "locked": { - "lastModified": 1667419884, - "narHash": "sha256-oLNw87ZI5NxTMlNQBv1wG2N27CUzo9admaFlnmavpiY=", + "lastModified": 1657835815, + "narHash": "sha256-CnZszAYpNKydh6N7+xg+eRtWNVoAAGqc6bg+Lpgq1xc=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "cfc0125eafadc9569d3d6a16ee928375b77e3100", + "rev": "54a24f042f93c79f5679f133faddedec61955cf2", "type": "github" }, "original": { @@ -100,7 +145,7 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "digga", "nixpkgs" @@ -143,16 +188,15 @@ "nixpkgs-unstable": "nixpkgs-unstable" }, "locked": { - "lastModified": 1661600857, - "narHash": "sha256-KfQCcTtfvU0PXV4fD9XKIMcKx9lUUR0xWJoBgc12fKE=", - "owner": "pub-solar", + "lastModified": 1659622306, + "narHash": "sha256-Kpfm2PNs+kZU0W7qcugoPATLG8I2P7FJFGTgsf1LJiU=", + "owner": "divnix", "repo": "digga", - "rev": "c902b3ef0aa45cb4f336c390f647bb182c38a221", + "rev": "d1193743a535d7fbbc7f3eda4e51295b10bd4d2c", "type": "github" }, "original": { - "owner": "pub-solar", - "ref": "fix/bootstrap-iso", + "owner": "divnix", "repo": "digga", "type": "github" } @@ -192,27 +236,11 @@ "flake-compat_3": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1648199409, + "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_4": { - "flake": false, - "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03", "type": "github" }, "original": { @@ -223,11 +251,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1642700792, - "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", "owner": "numtide", "repo": "flake-utils", - "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", "type": "github" }, "original": { @@ -238,7 +266,7 @@ }, "flake-utils-plus": { "inputs": { - "flake-utils": "flake-utils_2" + "flake-utils": "flake-utils_3" }, "locked": { "lastModified": 1654029967, @@ -256,6 +284,21 @@ } }, "flake-utils_2": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { "locked": { "lastModified": 1644229661, "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", @@ -270,13 +313,13 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_4": { "locked": { - "lastModified": 1667077288, - "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", "owner": "numtide", "repo": "flake-utils", - "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", "type": "github" }, "original": { @@ -292,11 +335,11 @@ ] }, "locked": { - "lastModified": 1667677389, - "narHash": "sha256-y9Zdq8vtsn0T5TO1iTvWA7JndYIAGjzCjbYVi/hOSmA=", + "lastModified": 1656169755, + "narHash": "sha256-Nlnm4jeQWEGjYrE6hxi/7HYHjBSZ/E0RtjCYifnNsWk=", "owner": "nix-community", "repo": "home-manager", - "rev": "87d55517f6f36aa1afbd7a4a064869d5a1d405b8", + "rev": "4a3d01fb53f52ac83194081272795aa4612c2381", "type": "github" }, "original": { @@ -324,11 +367,11 @@ }, "latest_2": { "locked": { - "lastModified": 1667629849, - "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", + "lastModified": 1660305968, + "narHash": "sha256-r0X1pZCSEA6mzt5OuTA7nHuLmvnbkwgpFAh1iLIx4GU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3bacde6273b09a21a8ccfba15586fb165078fb62", + "rev": "c4a0efdd5a728e20791b8d8d2f26f90ac228ee8d", "type": "github" }, "original": { @@ -345,11 +388,11 @@ ] }, "locked": { - "lastModified": 1662220400, - "narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=", + "lastModified": 1659610603, + "narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=", "owner": "nmattia", "repo": "naersk", - "rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3", + "rev": "c6a45e4277fa58abd524681466d3450f896dc094", "type": "github" }, "original": { @@ -375,11 +418,11 @@ }, "nixos": { "locked": { - "lastModified": 1667653703, - "narHash": "sha256-Xow4vx52/g5zkhlgZnMEm/TEXsj+13jTPCc2jIhW1xU=", + "lastModified": 1660318005, + "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f09ad462c5a121d0239fde645aacb2221553a217", + "rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f", "type": "github" }, "original": { @@ -392,14 +435,14 @@ "nixos-generators": { "inputs": { "nixlib": "nixlib", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1666812839, - "narHash": "sha256-0nBDgjPU+iDsvz89W+cDEyhnFGSwCJmwDl/gMGqYiU0=", + "lastModified": 1657748715, + "narHash": "sha256-WecDwDY/hEcDQYzFnccCNa+5Umht0lfjx/d1qGDy/rQ=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "41f3518bc194389df22a3d198215eae75e6b5ab9", + "rev": "3323b944d99b026aebfd8de439e001409dde067d", "type": "github" }, "original": { @@ -410,11 +453,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1667768008, - "narHash": "sha256-PGbX0s2hhXGnZDFVE6UIhPSOf5YegpWs5dUXpT/14F0=", + "lastModified": 1660407119, + "narHash": "sha256-04lWO0pDbhAXFdL4v2VzzwgxrZ5IefKn+TmZPiPeKxg=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "f6483e0def85efb9c1e884efbaff45a5e7aabb34", + "rev": "12620020f76b1b5d2b0e6fbbda831ed4f5fe56e1", "type": "github" }, "original": { @@ -425,16 +468,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1637186689, - "narHash": "sha256-NU7BhgnwA/3ibmCeSzFK6xGi+Bari9mPfn+4cBmyEjw=", + "lastModified": 1633971123, + "narHash": "sha256-WmI4NbH1IPGFWVkuBkKoYgOnxgwSfWDgdZplJlQ93vA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7fad01d9d5a3f82081c00fb57918d64145dc904c", + "rev": "e4ef597edfd8a0ba5f12362932fc9b1dd01a0aef", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable-small", "repo": "nixpkgs", "type": "github" } @@ -455,6 +498,22 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1637186689, + "narHash": "sha256-NU7BhgnwA/3ibmCeSzFK6xGi+Bari9mPfn+4cBmyEjw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7fad01d9d5a3f82081c00fb57918d64145dc904c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nur": { "locked": { "lastModified": 0, @@ -469,18 +528,18 @@ }, "nvfetcher": { "inputs": { - "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_3", + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", "nixpkgs": [ "nixos" ] }, "locked": { - "lastModified": 1667620329, - "narHash": "sha256-v1Zk7rtEbAGpevBGPZvZBKpwbmw4I+uVwxvd+pBlp3o=", + "lastModified": 1654975372, + "narHash": "sha256-wkNZ16akgKViuZzE/IM+bux4uaJ04KIwUeexH8gBjgw=", "owner": "berberman", "repo": "nvfetcher", - "rev": "294826951113dcd3aa9abbcacfb1aa5b95a19116", + "rev": "d4b237c10f14f72f8266b0f658faad822e491e55", "type": "github" }, "original": { @@ -489,13 +548,40 @@ "type": "github" } }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "bud", + "beautysh", + "flake-utils" + ], + "nixpkgs": [ + "bud", + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1633382856, + "narHash": "sha256-hYlet806M9xJj4yxf0g5fhDT2IEUVIMAl7sqIeZ8DUM=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "705cbfa10e3d9bfed2e59e0256844ae3704dbd7e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", + "bud": "bud", "darwin": "darwin", "deploy": "deploy", "digga": "digga", - "flake-compat": "flake-compat_3", "home": "home", "latest": "latest_2", "naersk": "naersk", diff --git a/flake.nix b/flake.nix index cce3f8ee..85e05602 100644 --- a/flake.nix +++ b/flake.nix @@ -11,15 +11,16 @@ nixos.url = "github:nixos/nixpkgs/nixos-22.05"; latest.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-compat.url = "github:edolstra/flake-compat"; - flake-compat.flake = false; - - digga.url = "github:pub-solar/digga/fix/bootstrap-iso"; + digga.url = "github:divnix/digga"; digga.inputs.nixpkgs.follows = "nixos"; digga.inputs.nixlib.follows = "nixos"; digga.inputs.home-manager.follows = "home"; digga.inputs.deploy.follows = "deploy"; + bud.url = "github:divnix/bud"; + bud.inputs.nixpkgs.follows = "nixos"; + bud.inputs.devshell.follows = "digga/devshell"; + home.url = "github:nix-community/home-manager/release-22.05"; home.inputs.nixpkgs.follows = "nixos"; @@ -46,6 +47,7 @@ outputs = { self , digga + , bud , nixos , home , nixos-hardware @@ -95,29 +97,18 @@ imports = [ (digga.lib.importExportableModules ./modules) ]; modules = [ { lib.our = self.lib; } - # FIXME: upstream module causes a huge number of unnecessary - # dependencies to be pulled in for all systems -- many of them are - # graphical. should only be imported as needed. - # digga.nixosModules.bootstrapIso + 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 */ - bootstrap = { - modules = [ - digga.nixosModules.bootstrapIso - ]; - }; - PubSolarOS = { - tests = [ - (import ./tests/first-test.nix { pkgs = nixos.legacyPackages.x86_64-linux; lib = nixos.lib; }) - ]; - }; + PubSolarOS = { }; }; importables = rec { profiles = digga.lib.rakeLeaves ./profiles // { diff --git a/hosts/bootstrap.nix b/hosts/bootstrap.nix index 49422675..541ca6fb 100644 --- a/hosts/bootstrap.nix +++ b/hosts/bootstrap.nix @@ -1,20 +1,9 @@ -{ config, lib, pkgs, profiles, ... }: -with lib; -let - # Gets hostname of host to be bundled inside iso - # Copied from https://github.com/divnix/digga/blob/30ffa0b02272dc56c94fd3c7d8a5a0f07ca197bf/modules/bootstrap-iso.nix#L3-L11 - getFqdn = config: - let - net = config.networking; - fqdn = - if (net ? domain) && (net.domain != null) - then "${net.hostName}.${net.domain}" - else net.hostName; - in - fqdn; -in +{ profiles, ... }: { - # build with: `nix build ".#nixosConfigurations.bootstrap.config.system.build.isoImage"` + # 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.users.root # make sure to configure ssh keys @@ -24,28 +13,16 @@ in profiles.pub-solar-iso ]; - config = { - boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.enable = true; - # will be overridden by the bootstrapIso instrumentation - fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; + # will be overridden by the bootstrapIso instrumentation + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; - system.nixos.label = "PubSolarOS-" + config.system.nixos.version; - - # mkForce because a similar transformation gets double applied otherwise - # https://github.com/divnix/digga/blob/30ffa0b02272dc56c94fd3c7d8a5a0f07ca197bf/modules/bootstrap-iso.nix#L17 - # https://github.com/NixOS/nixpkgs/blob/aecd4d8349b94f9bd5718c74a5b789f233f67326/nixos/modules/installer/cd-dvd/installation-cd-base.nix#L21-L22 - isoImage = { - isoBaseName = mkForce (getFqdn config); - isoName = mkForce "${config.system.nixos.label}-${config.isoImage.isoBaseName}-${pkgs.stdenv.hostPlatform.system}.iso"; - }; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "21.05"; # Did you read the comment? - }; + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.05"; # Did you read the comment? } diff --git a/lib/compat/default.nix b/lib/compat/default.nix index ae3b4426..9d0c2837 100644 --- a/lib/compat/default.nix +++ b/lib/compat/default.nix @@ -1,14 +1,14 @@ let - lock = builtins.fromJSON (builtins.readFile builtins.path { path = ../../flake.lock; name = "lockPath"; }); + rev = "e7e5d481a0e15dcd459396e55327749989e04ce0"; flake = (import ( fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; + url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz"; + sha256 = "0zd3x46fswh5n6faq4x2kkpy6p3c6j593xbdlbsl40ppkclwc80x"; } ) { - src = builtins.path { path = ../../.; name = "projectRoot"; }; + src = ../../.; }); in flake diff --git a/modules/ci-runner/default.nix b/modules/ci-runner/default.nix deleted file mode 100644 index 1460ab16..00000000 --- a/modules/ci-runner/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ lib, config, pkgs, self, ... }: -with lib; -let - psCfg = config.pub-solar; - cfg = config.pub-solar.ci-runner; -in -{ - options.pub-solar.ci-runner = { - enable = mkEnableOption "Enables a systemd service that runs drone-ci-runner"; - }; - - config = mkIf cfg.enable { - systemd.user.services.ci-runner = { - enable = true; - - description = "CI runner for the PubSolarOS repository that can run test VM instances with KVM."; - - serviceConfig = { - Type = "simple"; - Restart = "always"; - }; - - path = [ - pkgs.git - pkgs.nix - pkgs.libvirt - ]; - - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" "libvirtd.service" ]; - - script = ''${pkgs.drone-runner-exec}/bin/drone-runner-exec daemon /run/agenix/drone-runner-exec-config''; - }; - - age.secrets."drone-runner-exec-config" = { - file = "${self}/secrets/drone-runner-exec-config"; - mode = "700"; - owner = psCfg.user.name; - }; - }; -} diff --git a/modules/core/boot.nix b/modules/core/boot.nix index cb16865d..9e9af88e 100644 --- a/modules/core/boot.nix +++ b/modules/core/boot.nix @@ -9,34 +9,30 @@ in default = false; description = "Feature flag for iso builds"; }; - options.pub-solar.core.disk-encryption-active = mkOption { type = types.bool; default = true; description = "Whether it should be assumed that there is a cryptroot device"; }; - config = { - boot = { - # Enable plymouth for better experience of booting - plymouth.enable = mkIf (!cfg.lite) (lib.mkDefault true); + # Enable plymouth for better experience of booting + boot.plymouth.enable = true; - # Mount / luks device in initrd - # Allow fstrim to work on it. - # The ! makes this enabled by default - initrd = mkIf (!cfg.iso-options.enable && cfg.disk-encryption-active) { - luks.devices."cryptroot" = { - allowDiscards = true; - }; + # Mount / luks device in initrd + # Allow fstrim to work on it. + # The ! makes this enabled by default + boot.initrd = mkIf (!cfg.iso-options.enable && cfg.disk-encryption-active) { + luks.devices."cryptroot" = { + allowDiscards = true; }; - - loader.systemd-boot.enable = true; - - # Use latest LTS linux kernel by default - kernelPackages = pkgs.linuxPackages_5_15; - - # Support ntfs drives - supportedFilesystems = [ "ntfs" ]; }; + + boot.loader.systemd-boot.enable = true; + + # Use latest LTS linux kernel by default + boot.kernelPackages = pkgs.linuxPackages_5_15; + + # Support ntfs drives + boot.supportedFilesystems = [ "ntfs" ]; }; } diff --git a/modules/core/default.nix b/modules/core/default.nix index 4f74b46d..c7457c1b 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -2,12 +2,12 @@ with lib; let + psCfg = config.pub-solar; cfg = config.pub-solar.core; in { imports = [ ./boot.nix - ./hibernation.nix ./fonts.nix ./i18n.nix ./networking.nix @@ -28,14 +28,10 @@ in config = { pub-solar = { - audio.enable = mkIf (!cfg.lite) (mkDefault true); - crypto.enable = mkIf (!cfg.lite) (mkDefault true); - devops.enable = mkIf (!cfg.lite) (mkDefault true); - - terminal-life = { - enable = mkDefault true; - lite = cfg.lite; - }; + terminal-life.enable = true; + audio.enable = lib.mkIf (!cfg.lite) true; + crypto.enable = lib.mkIf (!cfg.lite) true; + devops.enable = lib.mkIf (!cfg.lite) true; }; }; } diff --git a/modules/core/hibernation.nix b/modules/core/hibernation.nix deleted file mode 100644 index a71ffd37..00000000 --- a/modules/core/hibernation.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.pub-solar.core.hibernation; -in -{ - options.pub-solar.core.hibernation = { - enable = mkOption { - type = types.bool; - default = false; - description = "Whether the device can hibernate. This creates a swapfile at /swapfile."; - }; - - resumeDevice = mkOption { - type = types.str; - default = "/dev/sda1"; - description = "The location of the hibernation resume swap file."; - }; - - resumeOffset = mkOption { - type = types.nullOr types.int; - default = null; - description = "The swap file offset. Can be found by running `filefrag -v $swap_file_location`. See https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file"; - }; - }; - - config = { - boot = mkIf cfg.enable { - resumeDevice = cfg.resumeDevice; - kernelParams = mkIf (cfg.resumeOffset != null) [ "resume_offset=${builtins.toString cfg.resumeOffset}" ]; - }; - }; -} diff --git a/modules/core/networking.nix b/modules/core/networking.nix index c5ec9cbe..ce3248d8 100644 --- a/modules/core/networking.nix +++ b/modules/core/networking.nix @@ -6,15 +6,6 @@ let cfg = config.pub-solar.core; in { options.pub-solar.core = { - enableCaddy = mkOption { - type = types.bool; - default = !cfg.lite; - }; - enableHelp = mkOption { - type = types.bool; - default = !cfg.lite; - }; - binaryCaches = mkOption { type = types.listOf types.str; default = [ ]; @@ -25,57 +16,39 @@ in default = [ ]; description = "Public keys of binary caches."; }; + iwdConfig = mkOption { + type = with types; nullOr (attrsOf (attrsOf (oneOf [ bool int str ]))); + default = null; + description = "Configuratoin of iNet Wireless Daemon."; + }; }; config = { - # disable NetworkManager-wait-online by default - systemd.services.NetworkManager-wait-online.enable = lib.mkDefault false; - networking.networkmanager = { # Enable networkmanager. REMEMBER to add yourself to group in order to use nm related stuff. enable = true; - wifi.backend = "iwd"; }; - networking.firewall.enable = true; - # Customized binary caches list (with fallback to official binary cache) nix.binaryCaches = cfg.binaryCaches; nix.binaryCachePublicKeys = cfg.publicKeys; # These entries get added to /etc/hosts networking.hosts = { - "127.0.0.1" = [ ] - ++ lib.optionals cfg.enableCaddy [ "caddy.local" ] - ++ lib.optionals config.pub-solar.printing.enable [ "cups.local" ] - ++ lib.optionals cfg.enableHelp [ "help.local" ]; + "127.0.0.1" = [ "cups.local" ]; }; # Caddy reverse proxy for local services like cups services.caddy = { - enable = cfg.enableCaddy; + enable = true; globalConfig = '' - default_bind 127.0.0.1 auto_https off ''; - extraConfig = concatStringsSep "\n" [ - (lib.optionalString - config.pub-solar.printing.enable - '' - cups.local:80 { - request_header Host localhost:631 - reverse_proxy unix//run/cups/cups.sock - } - '') - - (lib.optionalString - cfg.enableHelp - '' - help.local:80 { - root * ${pkgs.psos-docs}/lib/html - file_server - } - '') - ]; + extraConfig = '' + cups.local:80 + bind 127.0.0.1 + request_header Host localhost:631 + reverse_proxy unix//run/cups/cups.sock + ''; }; }; } diff --git a/modules/core/nix.nix b/modules/core/nix.nix index f7ff5fa4..38b70cfc 100644 --- a/modules/core/nix.nix +++ b/modules/core/nix.nix @@ -2,8 +2,6 @@ { nix = { - # Use default version alias for nix package - package = pkgs.nix; # Improve nix store disk usage autoOptimiseStore = true; gc.automatic = true; diff --git a/modules/core/services.nix b/modules/core/services.nix index 6ce74472..61ba6ea0 100644 --- a/modules/core/services.nix +++ b/modules/core/services.nix @@ -4,10 +4,7 @@ # For rage encryption, all hosts need a ssh key pair services.openssh = { enable = true; - # If you don't want the host to have SSH actually opened up to the net, - # set `services.openssh.openFirewall` to false in your config. - openFirewall = lib.mkDefault true; - passwordAuthentication = false; + openFirewall = lib.mkDefault false; }; # Service that makes Out of Memory Killer more effective diff --git a/modules/graphical/alacritty.nix b/modules/graphical/alacritty.nix index b389343c..e4e2f6ad 100644 --- a/modules/graphical/alacritty.nix +++ b/modules/graphical/alacritty.nix @@ -100,15 +100,10 @@ foreground = "0xe3e1e4"; }; - # Cursor colors - # - # Colors which should be used to draw the terminal cursor. - # - # Allowed values are CellForeground/CellBackground, which reference the - # affected cell, or hexadecimal colors like #ff00ff. + # Colors the cursor will use if `custom_cursor_colors` is true cursor = { - text = "CellBackground"; - cursor = "CellForeground"; + text = "0x1a181a"; + cursor = "0xe3e1e4"; }; # Colors used for the search bar and match highlighting. @@ -120,25 +115,14 @@ background = "0x1a181a"; }; focused_match = { - foreground = "CellBackground"; - background = "CellForeground"; + foreground = "0xe5c463"; + background = "0xe3e1e4"; }; #bar = # background = "#c5c8c6"; # foreground = "#1d1f21"; }; - # Selection colors - # - # Colors which should be used to draw the selection area. - # - # Allowed values are CellForeground/CellBackground, which reference the - # affected cell, or hexadecimal colors like #ff00ff. - selection = { - text = "0x1a181a"; - background = "0xf85e84"; - }; - # Normal colors normal = { black = "0x1a181a"; diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix index ede262b3..a506c2ef 100644 --- a/modules/graphical/default.nix +++ b/modules/graphical/default.nix @@ -61,7 +61,7 @@ in }; }; - services.getty.autologinUser = mkIf cfg.autologin.enable (mkForce "${psCfg.user.name}"); + services.getty.autologinUser = mkIf cfg.autologin.enable "${psCfg.user.name}"; qt5 = { enable = true; diff --git a/modules/paranoia/default.nix b/modules/paranoia/default.nix deleted file mode 100644 index 2dc439cf..00000000 --- a/modules/paranoia/default.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, lib, ... }: - -with lib; -let - psCfg = config.pub-solar; - cfg = config.pub-solar.paranoia; -in -{ - options.pub-solar.paranoia = { - enable = mkOption { - description = '' - Only offer hibernation instead of screen locking and sleeping. This only makes sense - if your hard drive is encrypted, and ensures that the contents of your drive are - encrypted if you are not actively using the device. - ''; - default = false; - type = types.bool; - }; - }; - - config = mkIf cfg.enable { - pub-solar.core.hibernation.enable = true; - services.logind.lidSwitch = "hibernate"; - - # The options below are directly taken from or inspired by - # https://xeiaso.net/blog/paranoid-nixos-2021-07-18 - - # Don't set this if you need sftp - services.openssh.allowSFTP = false; - services.openssh.openFirewall = false; # Lock yourself out - - # Limit the use of sudo to the group wheel - security.sudo.execWheelOnly = true; - - # Remove the complete default environment of packages like - # nano, perl and rsync - environment.defaultPackages = lib.mkForce [ ]; - - # fileSystems."/".options = [ "noexec" ]; - - services.openssh = { - kbdInteractiveAuthentication = false; - extraConfig = '' - AllowTcpForwarding yes - X11Forwarding no - AllowAgentForwarding no - AllowStreamLocalForwarding no - AuthenticationMethods publickey - ''; - }; - }; -} diff --git a/modules/sway/config/config.d/applications.conf b/modules/sway/config/config.d/applications.conf index 00eecef3..3bab265d 100644 --- a/modules/sway/config/config.d/applications.conf +++ b/modules/sway/config/config.d/applications.conf @@ -14,9 +14,8 @@ assign [app_id="telegramdesktop"] $ws4 # Launcher for_window [app_id="launcher" title="Alacritty"] floating enable, border pixel 10, sticky enable -for_window [app_id="pavucontrol"] floating enable, border pixel 10, sticky enable - # Floating menus +for_window [app_id="pavucontrol"] floating enable for_window [app_id="blueman-manager"] floating enable # Open specific applications in floating mode @@ -61,13 +60,9 @@ for_window [window_type="dialog"] floating enable for_window [window_type="menu"] floating enable for_window [title="About Mozilla Firefox"] floating enable for_window [title="Password Required - Mozilla Firefox"] floating enable -for_window [title="Extension: (Open in Browser)*"] floating enable - -# Technical media stuff happens on ws7 -for_window [app_id="screen-recorder" title="Alacritty"] move to workspace $ws7, floating disable -no_focus [app_id="screen-recorder"] -for_window [title="Firefox — Sharing Indicator"] move to workspace $ws7, floating disable +for_window [title="Firefox — Sharing Indicator"] move to workspace $ws7, floating enable no_focus [title="Firefox — Sharing Indicator"] +for_window [title="Extension: (Open in Browser)*"] floating enable # qMasterPassword floating menu for_window [title="qMasterPassword"] focus diff --git a/modules/sway/config/config.d/custom-keybindings.conf b/modules/sway/config/config.d/custom-keybindings.conf index 1b851675..bb452ddc 100644 --- a/modules/sway/config/config.d/custom-keybindings.conf +++ b/modules/sway/config/config.d/custom-keybindings.conf @@ -13,26 +13,37 @@ bindsym $mod+Ctrl+m exec pavucontrol ################################################################################################ # Quickstart application shortcuts -bindsym $mod+F1 exec psos help -bindsym $mod+Shift+h exec psos help - +bindsym $mod+F1 exec qMasterPassword bindsym $mod+F2 exec firefox - bindsym $mod+F3 exec $term -e vifm bindsym $mod+Shift+F3 exec gksu $term -e vifm - bindsym $mod+F4 exec nautilus -w bindsym $mod+Shift+F4 exec signal-desktop --use-tray-icon +bindsym $mod+F5 exec $term -e 'mocp -C $XDG_CONFIG_DIR/mocp/config' +bindsym $mod+Shift+m exec mu +bindsym $mod+Shift+h exec xdg-open /usr/share/doc/manjaro/i3_help.pdf -bindsym $mod+Shift+m exec qMasterPassword - -# Screenshots and screen recordings +# Screenshofts bindsym $mod+Ctrl+p exec grim -g "$(slurp -d -b \#ffffff11)" ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png bindsym $mod+Shift+p exec grim ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png bindsym $mod+Ctrl+f exec "( pkill flameshot || true && flameshot & ) && ( sleep 0.5s && flameshot gui )" -bindsym $mod+Ctrl+r exec record-screen - # Launcher set $menu exec alacritty --class launcher -e env TERMINAL_COMMAND="alacritty -e" sway-launcher bindsym $mod+Space exec $menu + +# Set shut down, restart and locking features +set $mode_system (l)ock, (e)xit, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown +bindsym $mod+0 mode "$mode_system" +mode "$mode_system" { + bindsym l exec swaylock-bg, mode "default" + bindsym e exec systemctl --user stop graphical-session.target, mode "default" + bindsym s exec systemctl suspend, mode "default" + bindsym h exec systemctl hibernate, mode "default" + bindsym r exec systemctl reboot, mode "default" + bindsym Shift+s exec systemctl poweroff, mode "default" + + # exit system mode: "Enter" or "Escape" + bindsym Return mode "default" + bindsym Escape mode "default" +} diff --git a/modules/sway/config/config.d/mode_system.conf.nix b/modules/sway/config/config.d/mode_system.conf.nix deleted file mode 100644 index f01921c4..00000000 --- a/modules/sway/config/config.d/mode_system.conf.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, psCfg, ... }: '' - # Set shut down, restart and locking features -'' + (if psCfg.core.hibernation.enable && !psCfg.paranoia.enable then '' - set $mode_system (e)xit, (h)ibernate, (l)ock, (s)uspend, (r)eboot, (Shift+s)hutdown -'' else if psCfg.paranoia.enable then '' - set $mode_system (e)xit, (h)ibernate, (r)eboot, (Shift+s)hutdown -'' else '' - set $mode_system (e)xit, (l)ock, (s)uspend, (r)eboot, (Shift+s)hutdown -'') -+ '' - bindsym $mod+0 mode "$mode_system" - mode "$mode_system" { - bindsym e exec swaymsg exit, mode "default" -'' + (if psCfg.core.hibernation.enable then '' - bindsym h exec systemctl hibernate, mode "default" -'' else "") -+ (if !psCfg.paranoia.enable then '' - bindsym l exec ${pkgs.swaylock-bg}/bin/swaylock-bg, mode "default" - bindsym s exec systemctl suspend, mode "default" -'' else "") + '' - bindsym r exec systemctl reboot, mode "default" - bindsym Shift+s exec systemctl poweroff, mode "default" - - # exit system mode: "Enter" or "Escape" - bindsym Return mode "default" - bindsym Escape mode "default" - } -'' diff --git a/modules/sway/config/config.d/systemd.conf b/modules/sway/config/config.d/systemd.conf index 66759c4f..d6380d41 100644 --- a/modules/sway/config/config.d/systemd.conf +++ b/modules/sway/config/config.d/systemd.conf @@ -5,4 +5,4 @@ # https://github.com/swaywm/sway/wiki/Systemd-integration # Also, import the most important environment variables into the D-Bus and systemd # user environments (e.g. required for screen sharing and Pinentry prompts): -exec "systemctl --user import-environment; systemctl --user start sway-session.target; exec dbus-update-activation-environment --systemd $IMPORT_ENVIRONMENT_ENV_LIST DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP; systemd-cat --identifier=sway sway" +exec "systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP; systemctl --user start sway-session.target; exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP; systemd-cat --identifier=sway sway" diff --git a/modules/sway/config/config.nix b/modules/sway/config/config.nix index 2375d616..8e21ec02 100644 --- a/modules/sway/config/config.nix +++ b/modules/sway/config/config.nix @@ -50,7 +50,7 @@ floating_modifier $mod normal # Reload the configuration file - bindsym $mod+F5 reload + bindsym $mod+Ctrl+r reload # # Moving around: diff --git a/modules/sway/default.nix b/modules/sway/default.nix index c173e9ce..35013dd2 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -2,26 +2,25 @@ with lib; let psCfg = config.pub-solar; + cfg = config.pub-solar.sway; in { options.pub-solar.sway = { enable = mkEnableOption "Life in boxes"; - - terminal = mkOption { - type = types.nullOr types.str; - default = "alacritty"; - description = "Choose sway's default terminal"; - }; - - v4l2loopback.enable = mkOption { - type = types.bool; - default = true; - description = "WebCam streaming tool"; - }; + }; + options.pub-solar.sway.terminal = mkOption { + type = types.nullOr types.str; + default = "alacritty"; + description = "Choose sway's default terminal"; + }; + options.pub-solar.sway.v4l2loopback.enable = mkOption { + type = types.bool; + default = true; + description = "WebCam streaming tool"; }; - config = mkIf psCfg.sway.enable (mkMerge [ - (mkIf (psCfg.sway.v4l2loopback.enable) { + config = mkIf cfg.enable (mkMerge [ + (mkIf (cfg.v4l2loopback.enable) { boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; boot.kernelModules = [ "v4l2loopback" ]; boot.extraModprobeConfig = '' @@ -76,8 +75,8 @@ in xsettingsd ydotool + swaylock-bg sway-launcher - record-screen import-gtk-settings s wcwd @@ -86,19 +85,18 @@ in programs.waybar.enable = true; #programs.waybar.systemd.enable = true; - systemd.user.services.mako = import ./mako.service.nix { inherit pkgs psCfg; }; - systemd.user.services.sway = import ./sway.service.nix { inherit pkgs psCfg; }; - systemd.user.services.swayidle = import ./swayidle.service.nix { inherit pkgs psCfg; }; - systemd.user.services.xsettingsd = import ./xsettingsd.service.nix { inherit pkgs psCfg; }; - systemd.user.services.waybar = import ./waybar.service.nix { inherit pkgs psCfg; }; - systemd.user.targets.sway-session = import ./sway-session.target.nix { inherit pkgs psCfg; }; + systemd.user.services.mako = import ./mako.service.nix pkgs; + systemd.user.services.sway = import ./sway.service.nix pkgs; + systemd.user.services.swayidle = import ./swayidle.service.nix pkgs; + systemd.user.services.xsettingsd = import ./xsettingsd.service.nix pkgs; + systemd.user.services.waybar = import ./waybar.service.nix pkgs; + systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs; xdg.configFile."sway/config".text = import ./config/config.nix { inherit config pkgs; }; xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf; xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf; xdg.configFile."sway/config.d/gaps.conf".source = ./config/config.d/gaps.conf; xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf; - xdg.configFile."sway/config.d/mode_system.conf".text = import ./config/config.d/mode_system.conf.nix { inherit pkgs psCfg; }; xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf; xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf; }; diff --git a/modules/sway/gammastep.service.nix b/modules/sway/gammastep.service.nix index 3960d1ae..f59edf02 100644 --- a/modules/sway/gammastep.service.nix +++ b/modules/sway/gammastep.service.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "set color temperature of display according to time of day"; diff --git a/modules/sway/libinput-gestures.service.nix b/modules/sway/libinput-gestures.service.nix index 798d10d6..c4c860da 100644 --- a/modules/sway/libinput-gestures.service.nix +++ b/modules/sway/libinput-gestures.service.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "Actions gestures on your touchpad using libinput"; diff --git a/modules/sway/mako.service.nix b/modules/sway/mako.service.nix index 1f210c74..190b986d 100644 --- a/modules/sway/mako.service.nix +++ b/modules/sway/mako.service.nix @@ -1,10 +1,11 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "Lightweight Wayland notification daemon"; Documentation = [ "man:mako(1)" ]; BindsTo = [ "sway-session.target" ]; After = [ "sway-session.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; }; Service = { diff --git a/modules/sway/sway-session.target.nix b/modules/sway/sway-session.target.nix index 7b25376a..3eb4d24c 100644 --- a/modules/sway/sway-session.target.nix +++ b/modules/sway/sway-session.target.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "sway compositor session"; diff --git a/modules/sway/sway.service.nix b/modules/sway/sway.service.nix index 0d0d782c..95efc3e6 100644 --- a/modules/sway/sway.service.nix +++ b/modules/sway/sway.service.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "sway - SirCmpwn's Wayland window manager"; diff --git a/modules/sway/swayidle.service.nix b/modules/sway/swayidle.service.nix index 80a04518..597a8779 100644 --- a/modules/sway/swayidle.service.nix +++ b/modules/sway/swayidle.service.nix @@ -1,4 +1,4 @@ -{ pkgs, psCfg, ... }: +pkgs: { Unit = { Description = "Idle manager for Wayland"; @@ -9,16 +9,13 @@ }; Service = { Type = "simple"; - Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swaylock-bg}/bin:${pkgs.swayidle}/bin"; - ExecStart = ''swayidle -w \ - after-resume 'swaymsg "output * dpms on"' \ - before-sleep 'swaylock-bg' '' + (if psCfg.paranoia.enable then '' \ - timeout 120 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \ - timeout 150 'systemctl hibernate' - '' else '' \ - timeout 600 'swaylock-bg' \ - timeout 900 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' - ''); + Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swaylock}/bin:${pkgs.swaylock-bg}/bin"; + ExecStart = ''${pkgs.swayidle}/bin/swayidle -w \ + timeout 600 'swaylock-bg' \ + timeout 900 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + before-sleep 'swaylock-bg' + ''; }; Install = { WantedBy = [ "sway-session.target" ]; diff --git a/modules/sway/waybar.service.nix b/modules/sway/waybar.service.nix index 0237612f..ee5e8938 100644 --- a/modules/sway/waybar.service.nix +++ b/modules/sway/waybar.service.nix @@ -1,12 +1,11 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors."; Documentation = "https://github.com/Alexays/Waybar/wiki/"; BindsTo = [ "sway-session.target" ]; - After = [ "sway-session.target" "network-online.target" ]; + After = [ "graphical-session-pre.target" "network-online.target" ]; Wants = [ "graphical-session-pre.target" "network-online.target" "blueman-applet.service" ]; - ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; }; Service = { diff --git a/modules/sway/xsettingsd.service.nix b/modules/sway/xsettingsd.service.nix index db3e842c..0d729cb2 100644 --- a/modules/sway/xsettingsd.service.nix +++ b/modules/sway/xsettingsd.service.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "X Settings Daemon"; diff --git a/modules/sway/ydotool.service.nix b/modules/sway/ydotool.service.nix index 24b64432..d53bfcd7 100644 --- a/modules/sway/ydotool.service.nix +++ b/modules/sway/ydotool.service.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +pkgs: { Unit = { Description = "ydotool - Generic command-line automation tool (no X!)"; diff --git a/modules/terminal-life/default.nix b/modules/terminal-life/default.nix index 6bd0312f..8ecb9919 100644 --- a/modules/terminal-life/default.nix +++ b/modules/terminal-life/default.nix @@ -7,14 +7,6 @@ in { options.pub-solar.terminal-life = { enable = mkEnableOption "Life in black and white"; - - lite = mkOption { - description = '' - Enable a lite edition of terminal-life with less modules and a reduced package set. - ''; - default = false; - type = types.bool; - }; }; config = mkIf cfg.enable { diff --git a/modules/terminal-life/nvim/default.nix b/modules/terminal-life/nvim/default.nix index 4df1892a..1d6645ff 100644 --- a/modules/terminal-life/nvim/default.nix +++ b/modules/terminal-life/nvim/default.nix @@ -1,10 +1,69 @@ { config, pkgs, ... }: let psCfg = config.pub-solar; - cfg = config.pub-solar.terminal-life; xdg = config.home-manager.users."${psCfg.user.name}".xdg; preview-file = pkgs.writeShellScriptBin "preview-file" (import ./preview-file.nix pkgs); + + vimagit-master = pkgs.vimUtils.buildVimPlugin { + name = "vimagit-master"; + src = pkgs.fetchFromGitHub { + owner = "jreybert"; + repo = "vimagit"; + rev = "308650ddc1e9a94e49fae0ea04bbc1c45f23d4c4"; + sha256 = "sha256-fhazQQqyFaO0fdoeNI9nBshwTDhKNHH262H/QThtuO0="; + }; + }; + + instant-nvim = pkgs.vimUtils.buildVimPlugin { + name = "instant"; + src = pkgs.fetchFromGitHub { + owner = "jbyuki"; + repo = "instant.nvim"; + rev = "c02d72267b12130609b7ad39b76cf7f4a3bc9554"; + sha256 = "sha256-7Pr2Au/oGKp5kMXuLsQY4BK5Wny9L1EBdXtyS5EaZPI="; + }; + }; + + vim-caddyfile = pkgs.vimUtils.buildVimPlugin { + name = "vim-caddyfile"; + src = pkgs.fetchFromGitHub { + owner = "isobit"; + repo = "vim-caddyfile"; + rev = "24fe0720551883e407cb70ae1d7c03f162d1d5a0"; + sha256 = "sha256-rRYv3vnt31g7hNTxttTD6BWdv5JJ+ko3rPNyDUEOZ9o="; + }; + }; + + workspace = pkgs.vimUtils.buildVimPlugin { + name = "vim-workspace"; + src = pkgs.fetchFromGitHub { + owner = "thaerkh"; + repo = "vim-workspace"; + rev = "c26b473f9b073f24bacecd38477f44c5cd1f5a62"; + sha256 = "sha256-XV7opLyfkHIDO0+JJaO/x0za0gsHuklrzapTGdLHJmI="; + }; + }; + + beautify = pkgs.vimUtils.buildVimPlugin { + name = "vim-beautify"; + src = pkgs.fetchFromGitHub { + owner = "zeekay"; + repo = "vim-beautify"; + rev = "e0691483927dc5a0c051433602397419f9628623"; + sha256 = "QPTCl6KaGcAjTS5yVDov9yxmv0fDaFoPLMsrtVIG6GQ="; + }; + }; + + apprentice = pkgs.vimUtils.buildVimPlugin { + name = "vim-apprentice"; + src = pkgs.fetchFromGitHub { + owner = "romainl"; + repo = "Apprentice"; + rev = "ecd41698037f15a58125b349be76dbd2595bfb6d"; + sha256 = "sha256-9s7Yzn3IEJBjcyUq9NBIQ9wb45Xr7jOkEIoWf0lAYYg="; + }; + }; in { enable = true; @@ -17,7 +76,7 @@ in withRuby = true; withPython3 = true; - extraPackages = with pkgs; lib.mkIf (!cfg.lite) [ + extraPackages = with pkgs; [ ccls gopls nodejs @@ -48,7 +107,7 @@ in lsp_extensions-nvim nvim-lspconfig - instant-nvim-nvfetcher + instant-nvim ack-vim vim-airline @@ -59,23 +118,23 @@ in syntastic vim-gutentags vim-vinegar - vim-workspace-nvfetcher + workspace sonokai vim-hybrid-material vim-airline-themes - vim-apprentice-nvfetcher + apprentice fugitive vim-gitgutter vim-rhubarb - vimagit-nvfetcher + vimagit-master fzf-vim fzfWrapper vim-highlightedyank - vim-beautify-nvfetcher + beautify vim-surround vim-bufkill @@ -84,7 +143,7 @@ in ansible-vim emmet-vim rust-vim - vim-caddyfile-nvfetcher + vim-caddyfile vim-go vim-javascript vim-json diff --git a/modules/terminal-life/zsh/default.nix b/modules/terminal-life/zsh/default.nix index 36ec41ad..2db8bc41 100644 --- a/modules/terminal-life/zsh/default.nix +++ b/modules/terminal-life/zsh/default.nix @@ -39,30 +39,21 @@ in nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; }; - plugins = [ - # src gets fetched by nvfetcher, see: ./pkgs/sources.toml - { - # will source ohmyzsh/plugins/z/ - name = "zsh-plugins-z"; - file = "plugins/z/z.plugin.zsh"; - src = pkgs.sources.ohmyzsh.src; - } - { - name = "zsh-powerlevel10k"; - file = "powerlevel10k.zsh-theme"; - src = pkgs.sources.powerlevel10k.src; - } - { - name = "zsh-fast-syntax-highlighting"; - file = "F-Sy-H.plugin.zsh"; - src = pkgs.sources.F-Sy-H.src; - } - { - name = "zsh-nix-shell"; - file = "nix-shell.plugin.zsh"; - src = pkgs.sources.zsh-nix-shell.src; - } - ]; + zplug = { + enable = true; + plugins = [ + { + name = "plugins/z"; + tags = [ "from:oh-my-zsh" ]; + } + { + name = "romkatv/powerlevel10k"; + tags = [ "as:theme" "depth:1" ]; + } + { name = "zdharma/fast-syntax-highlighting"; } + { name = "chisui/zsh-nix-shell"; } + ]; + }; initExtra = '' bindkey -v diff --git a/modules/user/default.nix b/modules/user/default.nix index 7c869380..2fd5958e 100644 --- a/modules/user/default.nix +++ b/modules/user/default.nix @@ -23,7 +23,7 @@ in }; publicKeys = mkOption { description = "User SSH public keys"; - type = types.listOf types.str; + type = types.listOf types.path; default = [ ]; }; fullName = mkOption { diff --git a/overlays/neovim-plugins.nix b/overlays/neovim-plugins.nix deleted file mode 100644 index b022049c..00000000 --- a/overlays/neovim-plugins.nix +++ /dev/null @@ -1,22 +0,0 @@ -final: prev: { - vimPlugins = prev.vimPlugins // { - instant-nvim-nvfetcher = prev.vimUtils.buildVimPluginFrom2Nix { - inherit (prev.sources.instant-nvim-nvfetcher) pname version src; - }; - vimagit-nvfetcher = prev.vimUtils.buildVimPluginFrom2Nix { - inherit (prev.sources.vimagit-nvfetcher) pname version src; - }; - vim-caddyfile-nvfetcher = prev.vimUtils.buildVimPluginFrom2Nix { - inherit (prev.sources.vim-caddyfile-nvfetcher) pname version src; - }; - vim-workspace-nvfetcher = prev.vimUtils.buildVimPluginFrom2Nix { - inherit (prev.sources.vim-workspace-nvfetcher) pname version src; - }; - vim-beautify-nvfetcher = prev.vimUtils.buildVimPluginFrom2Nix { - inherit (prev.sources.vim-beautify-nvfetcher) pname version src; - }; - vim-apprentice-nvfetcher = prev.vimUtils.buildVimPluginFrom2Nix { - inherit (prev.sources.vim-apprentice-nvfetcher) pname version src; - }; - }; -} diff --git a/overlays/overrides.nix b/overlays/overrides.nix index 4159bf32..fd0b836f 100644 --- a/overlays/overrides.nix +++ b/overlays/overrides.nix @@ -8,7 +8,6 @@ channels: final: prev: { discord element-desktop rage - nix-index nixpkgs-fmt qutebrowser signal-desktop diff --git a/overlays/rnix-lsp.nix b/overlays/rnix-lsp.nix index f755d110..62c0f2b0 100644 --- a/overlays/rnix-lsp.nix +++ b/overlays/rnix-lsp.nix @@ -1,6 +1,13 @@ final: prev: { rnix-lsp = prev.rnix-lsp.overrideAttrs (oldAttrs: rec { - inherit (prev.sources.rnix-lsp-nvfetcher) pname version src; + version = "unstable-2022-07-28"; + + src = prev.fetchFromGitHub { + owner = "nix-community"; + repo = "rnix-lsp"; + rev = "ff18e04551a39ccdab0ff9c83926db3807b23478"; + sha256 = "sha256-4OIpATLdPQvryyhRQPELeqNYC0n6PCyjD6LCPdwOztc="; + }; cargoDeps = oldAttrs.cargoDeps.overrideAttrs (prev.lib.const { name = "rnix-lsp-vendor.tar.gz"; diff --git a/pkgs/_sources/generated.nix b/pkgs/_sources/generated.nix index 30bcbdef..71be3965 100644 --- a/pkgs/_sources/generated.nix +++ b/pkgs/_sources/generated.nix @@ -1,136 +1,16 @@ # This file was generated by nvfetcher, please do not modify it manually. -{ fetchgit, fetchurl, fetchFromGitHub }: +{ fetchgit, fetchurl }: { - F-Sy-H = { - pname = "F-Sy-H"; - version = "b935a87a75560f8173dd78deee6717c59d464e06"; - src = fetchFromGitHub ({ - owner = "z-shell"; - repo = "F-Sy-H"; - rev = "b935a87a75560f8173dd78deee6717c59d464e06"; - fetchSubmodules = false; - sha256 = "sha256-448OlDnrDkUjvaSLDhXsa9bkgYXzj1Ju8CTpJVjH8LM="; - }); - }; - instant-nvim-nvfetcher = { - pname = "instant-nvim-nvfetcher"; - version = "294b6d08143b3db8f9db7f606829270149e1a786"; - src = fetchFromGitHub ({ - owner = "jbyuki"; - repo = "instant.nvim"; - rev = "294b6d08143b3db8f9db7f606829270149e1a786"; - fetchSubmodules = false; - sha256 = "sha256-DXJWji/NR8ZCxe014rD51v3EHJHMhRQeOoI3SsY8mR4="; - }); - }; manix = { pname = "manix"; version = "d08e7ca185445b929f097f8bfb1243a8ef3e10e4"; - src = fetchFromGitHub ({ - owner = "mlvzk"; - repo = "manix"; + src = fetchgit { + url = "https://github.com/mlvzk/manix"; rev = "d08e7ca185445b929f097f8bfb1243a8ef3e10e4"; fetchSubmodules = false; - sha256 = "sha256-GqPuYscLhkR5E2HnSFV4R48hCWvtM3C++3zlJhiK/aw="; - }); - }; - ohmyzsh = { - pname = "ohmyzsh"; - version = "65a1e4edbe678cdac37ad96ca4bc4f6d77e27adf"; - src = fetchFromGitHub ({ - owner = "ohmyzsh"; - repo = "ohmyzsh"; - rev = "65a1e4edbe678cdac37ad96ca4bc4f6d77e27adf"; - fetchSubmodules = false; - sha256 = "sha256-qyI7CU0vKhhADZfQtD73GsyAbqdMPhDQ1uA03h4erpw="; - }); - }; - powerlevel10k = { - pname = "powerlevel10k"; - version = "8091c8a3a8a845c70046684235a01cd500075def"; - src = fetchFromGitHub ({ - owner = "romkatv"; - repo = "powerlevel10k"; - rev = "8091c8a3a8a845c70046684235a01cd500075def"; - fetchSubmodules = false; - sha256 = "sha256-I0/tktXCbZ3hMYTNvPoWfOEYWRgmHoXsar/jcUB6bpo="; - }); - }; - rnix-lsp-nvfetcher = { - pname = "rnix-lsp-nvfetcher"; - version = "6925256babec4307479a4080b44f2be38056f210"; - src = fetchFromGitHub ({ - owner = "nix-community"; - repo = "rnix-lsp"; - rev = "6925256babec4307479a4080b44f2be38056f210"; - fetchSubmodules = false; - sha256 = "sha256-OKLyIXIXhUnRB3Xw+7zI3u6XkwF7Mrbfz1XaasV6i7Q="; - }); - }; - vim-apprentice-nvfetcher = { - pname = "vim-apprentice-nvfetcher"; - version = "9942d0bb0a5d82f7a24450b00051c1f2cc008659"; - src = fetchFromGitHub ({ - owner = "romainl"; - repo = "Apprentice"; - rev = "9942d0bb0a5d82f7a24450b00051c1f2cc008659"; - fetchSubmodules = false; - sha256 = "sha256-Xs+vTdnihNbBFPOKsW+NB40pqN9eaadqzc0DIeNoOFo="; - }); - }; - vim-beautify-nvfetcher = { - pname = "vim-beautify-nvfetcher"; - version = "e0691483927dc5a0c051433602397419f9628623"; - src = fetchFromGitHub ({ - owner = "zeekay"; - repo = "vim-beautify"; - rev = "e0691483927dc5a0c051433602397419f9628623"; - fetchSubmodules = false; - sha256 = "sha256-QPTCl6KaGcAjTS5yVDov9yxmv0fDaFoPLMsrtVIG6GQ="; - }); - }; - vim-caddyfile-nvfetcher = { - pname = "vim-caddyfile-nvfetcher"; - version = "24fe0720551883e407cb70ae1d7c03f162d1d5a0"; - src = fetchFromGitHub ({ - owner = "isobit"; - repo = "vim-caddyfile"; - rev = "24fe0720551883e407cb70ae1d7c03f162d1d5a0"; - fetchSubmodules = false; - sha256 = "sha256-rRYv3vnt31g7hNTxttTD6BWdv5JJ+ko3rPNyDUEOZ9o="; - }); - }; - vim-workspace-nvfetcher = { - pname = "vim-workspace-nvfetcher"; - version = "c26b473f9b073f24bacecd38477f44c5cd1f5a62"; - src = fetchFromGitHub ({ - owner = "thaerkh"; - repo = "vim-workspace"; - rev = "c26b473f9b073f24bacecd38477f44c5cd1f5a62"; - fetchSubmodules = false; - sha256 = "sha256-XV7opLyfkHIDO0+JJaO/x0za0gsHuklrzapTGdLHJmI="; - }); - }; - vimagit-nvfetcher = { - pname = "vimagit-nvfetcher"; - version = "308650ddc1e9a94e49fae0ea04bbc1c45f23d4c4"; - src = fetchFromGitHub ({ - owner = "jreybert"; - repo = "vimagit"; - rev = "308650ddc1e9a94e49fae0ea04bbc1c45f23d4c4"; - fetchSubmodules = false; - sha256 = "sha256-fhazQQqyFaO0fdoeNI9nBshwTDhKNHH262H/QThtuO0="; - }); - }; - zsh-nix-shell = { - pname = "zsh-nix-shell"; - version = "af6f8a266ea1875b9a3e86e14796cadbe1cfbf08"; - src = fetchFromGitHub ({ - owner = "chisui"; - repo = "zsh-nix-shell"; - rev = "af6f8a266ea1875b9a3e86e14796cadbe1cfbf08"; - fetchSubmodules = false; - sha256 = "sha256-BjgMhILEL/qdgfno4LR64LSB8n9pC9R+gG7IQWwgyfQ="; - }); + deepClone = false; + leaveDotGit = false; + sha256 = "1b7xi8c2drbwzfz70czddc4j33s7g1alirv12dwl91hbqxifx8qs"; + }; }; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 43f6d7b7..ecac30a3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -9,16 +9,14 @@ with final; { mopidy-jellyfin = import ./mopidy-jellyfin.nix final; mu = writeShellScriptBin "mu" (import ./mu.nix final); psos = writeShellScriptBin "psos" (import ./psos.nix final); - psos-docs = import ./psos-docs.nix final; s = writeShellScriptBin "s" (import ./s.nix final); sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final); sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final); - swaylock-bg = writeShellScriptBin "swaylock-bg" (import ./swaylock-bg.nix final); + swaylock-bg = writeScriptBin "swaylock-bg" (import ./swaylock-bg.nix final); toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final); uhk-agent = import ./uhk-agent.nix final; wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final); drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final); - record-screen = writeShellScriptBin "record-screen" (import ./record-screen.nix final); # ps-fixes } diff --git a/pkgs/drone-docker-runner.nix b/pkgs/drone-docker-runner.nix index e1773d5a..7d098536 100644 --- a/pkgs/drone-docker-runner.nix +++ b/pkgs/drone-docker-runner.nix @@ -6,7 +6,7 @@ self: with self; '' --env=DRONE_RPC_PROTO=$DRONE_RPC_PROTO \ --env=DRONE_RPC_HOST=$DRONE_RPC_HOST \ --env=DRONE_RPC_SECRET=$(${self.libsecret}/bin/secret-tool lookup drone rpc-secret) \ - --env=DRONE_RUNNER_CAPACITY=8 \ + --env=DRONE_RUNNER_CAPACITY=4 \ --env=DRONE_RUNNER_NAME=$(${self.inetutils}/bin/hostname) \ --publish=3000:3000 \ --restart=always \ diff --git a/pkgs/psos-docs.nix b/pkgs/psos-docs.nix deleted file mode 100644 index 112e39bc..00000000 --- a/pkgs/psos-docs.nix +++ /dev/null @@ -1,26 +0,0 @@ -self: with self; -stdenv.mkDerivation rec { - pname = "psos-docs"; - version = "0.0.1"; - buildInputs = [ - mdbook - mdbook-pdf - ]; - - src = ../docs/..; # wut - - phases = [ "buildPhase" "installPhase" ]; - - buildPhase = '' - cp -r $src/doc ./doc - cp $src/README.md ./README.md - chmod ug+w -R . - ls -la . - mdbook build doc - ''; - - installPhase = '' - mkdir -p $out/lib/ - cp -r doc/book $out/lib/html - ''; -} diff --git a/pkgs/psos.nix b/pkgs/psos.nix index eb050bfb..a60bad6d 100644 --- a/pkgs/psos.nix +++ b/pkgs/psos.nix @@ -14,10 +14,6 @@ self: with self; '' shift; exec nixos-option -I nixpkgs=/etc/nixos/lib/compat $@ ;; - help) - shift; - exec xdg-open http://help.local/ - ;; *) if [[ "$@" != "" ]]; then echo "Unknown command: psos $@" diff --git a/pkgs/record-screen.nix b/pkgs/record-screen.nix deleted file mode 100644 index d8d7f4a3..00000000 --- a/pkgs/record-screen.nix +++ /dev/null @@ -1,10 +0,0 @@ -self: with self; '' - mkdir -p "$HOME/Videos/Screenrecordings" - GEOMETRY="$(slurp -d -b \#ffffff11)" - RESOLUTION="$(echo $GEOMETRY | awk '{print $2}')" - FILE_LOCATION="$HOME/Videos/Screenrecordings/$(${coreutils}/bin/date +%Y%m%d_%Hh%Mm%Ss)_$RESOLUTION.mp4" - echo "Recording $GEOMETRY into $FILE_LOCATION" - ${alacritty}/bin/alacritty \ - --class screen-recorder \ - -e ${wf-recorder}/bin/wf-recorder -g "$GEOMETRY" -f "$FILE_LOCATION" -'' diff --git a/pkgs/sources.toml b/pkgs/sources.toml index 5ec5e936..f7af168e 100644 --- a/pkgs/sources.toml +++ b/pkgs/sources.toml @@ -2,47 +2,3 @@ [manix] src.git = "https://github.com/mlvzk/manix" fetch.github = "mlvzk/manix" - -[ohmyzsh] -src.git = "https://github.com/ohmyzsh/ohmyzsh" -fetch.github = "ohmyzsh/ohmyzsh" - -[powerlevel10k] -src.git = "https://github.com/romkatv/powerlevel10k" -fetch.github = "romkatv/powerlevel10k" - -[F-Sy-H] -src.git = "https://github.com/z-shell/F-Sy-H" -fetch.github = "z-shell/F-Sy-H" - -[zsh-nix-shell] -src.git = "https://github.com/chisui/zsh-nix-shell" -fetch.github = "chisui/zsh-nix-shell" - -[rnix-lsp-nvfetcher] -src.git = "https://github.com/nix-community/rnix-lsp" -fetch.github = "nix-community/rnix-lsp" - -[vimagit-nvfetcher] -src.git = "https://github.com/jreybert/vimagit" -fetch.github = "jreybert/vimagit" - -[instant-nvim-nvfetcher] -src.git = "https://github.com/jbyuki/instant.nvim" -fetch.github = "jbyuki/instant.nvim" - -[vim-caddyfile-nvfetcher] -src.git = "https://github.com/isobit/vim-caddyfile" -fetch.github = "isobit/vim-caddyfile" - -[vim-workspace-nvfetcher] -src.git = "https://github.com/thaerkh/vim-workspace" -fetch.github = "thaerkh/vim-workspace" - -[vim-beautify-nvfetcher] -src.git = "https://github.com/zeekay/vim-beautify" -fetch.github = "zeekay/vim-beautify" - -[vim-apprentice-nvfetcher] -src.git = "https://github.com/romainl/Apprentice" -fetch.github = "romainl/Apprentice" diff --git a/pkgs/sway-service.nix b/pkgs/sway-service.nix index 2ab84c62..f0b97ee7 100644 --- a/pkgs/sway-service.nix +++ b/pkgs/sway-service.nix @@ -1,6 +1,6 @@ self: with self; '' # first import environment variables from the login manager - systemctl --user import-environment; + systemctl --user import-environment # then start the service exec systemctl --wait --user start sway.service '' diff --git a/pkgs/swaylock-bg.nix b/pkgs/swaylock-bg.nix index 75bcd7de..b55c32ae 100644 --- a/pkgs/swaylock-bg.nix +++ b/pkgs/swaylock-bg.nix @@ -3,17 +3,18 @@ self: with self; '' # swaylock # Make sure we aren't running twice - RUNNING=$(${procps}/bin/pgrep -c ${swaylock}/bin/swaylock) - if [ "$RUNNING" -ne 0 ]; then + RUNNING=$(ps -A | grep swaylock | wc -l) + if [ $RUNNING -ne 0 ]; then exit 0 fi - IMAGE="$XDG_CONFIG_HOME/wallpaper.jpg" + IMAGE=$XDG_CONFIG_HOME/wallpaper.jpg LOCKARGS="" - for OUTPUT in $(${sway}/bin/swaymsg -t get_outputs | ${jq}/bin/jq -r '.[].name') + for OUTPUT in `${sway}/bin/swaymsg -t get_outputs | jq -r '.[].name'` do LOCKARGS="''${LOCKARGS} --image ''${OUTPUT}:''${IMAGE}" + IMAGES="''${IMAGES} ''${IMAGE}" done exec ${swaylock}/bin/swaylock $LOCKARGS '' diff --git a/profiles/base-user/default.nix b/profiles/base-user/default.nix index 374dca40..9ff21c8e 100644 --- a/profiles/base-user/default.nix +++ b/profiles/base-user/default.nix @@ -25,7 +25,7 @@ in ]; initialHashedPassword = if psCfg.user.password != null then psCfg.user.password else ""; shell = pkgs.zsh; - openssh.authorizedKeys.keys = if psCfg.user.publicKeys != null then psCfg.user.publicKeys else [ ]; + openssh.authorizedKeys.keyFiles = if psCfg.user.publicKeys != null then psCfg.user.publicKeys else [ ]; }; }; } diff --git a/profiles/base-user/session-variables.nix b/profiles/base-user/session-variables.nix index e922781b..5bbfa8ee 100644 --- a/profiles/base-user/session-variables.nix +++ b/profiles/base-user/session-variables.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, ... }: let psCfg = config.pub-solar; wlroots = psCfg.graphical.wayland; @@ -77,22 +77,10 @@ let # TELEMETRY BS VUEDX_TELEMETRY = "off"; }; - - envListNames = lib.attrsets.mapAttrsToList (name: value: name) variables; - - # Here we merge an extra variable into the attrset called FULL_ENV_LIST. - # It's a list of the variable names defined above. - # We can use this to tell `systemctl import-environment` to import the full list above. - variablesWithMeta = lib.attrsets.zipAttrsWith (name: values: builtins.head values) [ - variables - { IMPORT_ENVIRONMENT_ENV_LIST = lib.lists.foldl (a: b: a + " " + b) "IMPORT_ENVIRONMENT_ENV_LIST" envListNames; } - ]; in { home-manager = pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { - home.sessionVariables = variablesWithMeta; - systemd.user.sessionVariables = variablesWithMeta; + home.sessionVariables = variables; + systemd.user.sessionVariables = variables; }; - - environment.variables = variablesWithMeta; } diff --git a/shell/default.nix b/shell/default.nix index 597a2d2d..d22b3af4 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -1,6 +1,7 @@ { self, inputs, ... }: { modules = with inputs; [ + bud.devshellModules.bud ]; exportedModules = [ ./devos.nix diff --git a/shell/devos.nix b/shell/devos.nix index 382a6d34..2198052f 100644 --- a/shell/devos.nix +++ b/shell/devos.nix @@ -1,22 +1,12 @@ -{ pkgs, extraModulesPath, inputs, lib, ... }: +{ pkgs, extraModulesPath, inputs, ... }: let - inherit (pkgs) - agenix - cachix - editorconfig-checker - mdbook - nix - nixpkgs-fmt - nvfetcher - ; - hooks = import ./hooks; pkgWithCategory = category: package: { inherit package category; }; - devos = pkgWithCategory "devos"; linter = pkgWithCategory "linter"; docs = pkgWithCategory "docs"; + devos = pkgWithCategory "devos"; in { @@ -28,6 +18,21 @@ in # override for our own welcome devshell.name = pkgs.lib.mkForce "PubSolarOS"; + # 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 + ''); + commands = with pkgs; [ (devos nix) (devos agenix) @@ -39,15 +44,15 @@ in } (linter nixpkgs-fmt) (linter editorconfig-checker) - + # (docs python3Packages.grip) too many deps (docs mdbook) - ] - ++ lib.optionals (!pkgs.stdenv.buildPlatform.isi686) [ - (devos cachix) - ] - ++ lib.optionals (pkgs.stdenv.hostPlatform.isLinux && !pkgs.stdenv.buildPlatform.isDarwin) [ - (devos inputs.nixos-generators.defaultPackage.${pkgs.system}) (devos deploy-rs) ] + ++ lib.optional + (system != "i686-linux") + (devos cachix) + ++ lib.optional + (system != "aarch64-darwin") + (devos inputs.nixos-generators.defaultPackage.${pkgs.system}) ; } diff --git a/shell/hooks/pre-commit.sh b/shell/hooks/pre-commit.sh index a7fa9083..985d3b40 100755 --- a/shell/hooks/pre-commit.sh +++ b/shell/hooks/pre-commit.sh @@ -14,16 +14,13 @@ nix_files=($($diff -- '*.nix')) all_files=($($diff)) # Format staged nix files. -if (( ${#nix_files[@]} != 0 )); then +if [[ -n "${nix_files[@]}" ]]; then nixpkgs-fmt "${nix_files[@]}" \ && git add "${nix_files[@]}" fi # check editorconfig -if (( ${#all_files[@]} != 0 )); then - editorconfig-checker -- "${all_files[@]}" -fi - +editorconfig-checker -- "${all_files[@]}" if [[ $? != '0' ]]; then printf "%b\n" \ "\nCode is not aligned with .editorconfig" \ diff --git a/tests/first-test.nix b/tests/first-test.nix deleted file mode 100644 index 251779a1..00000000 --- a/tests/first-test.nix +++ /dev/null @@ -1,87 +0,0 @@ -{ pkgs, lib, ... }: -{ - name = "firstTest"; - - nodes.test-machine = { suites ? null, ... }: { - imports = suites.iso; - - home-manager.users.pub-solar.programs.zsh.shellAliases = { - test-x11 = "glinfo | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok"; - test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok"; - }; - - # source: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/tests/sway.nix - environment = { - # For glinfo and wayland-info: - systemPackages = with pkgs; [ mesa-demos wayland-utils alacritty ]; - # Use a fixed SWAYSOCK path (for swaymsg): - variables = { - "SWAYSOCK" = "/tmp/sway-ipc.sock"; - # TODO: Investigate if we can get hardware acceleration to work (via - # virtio-gpu and Virgil). We currently have to use the Pixman software - # renderer since the GLES2 renderer doesn't work inside the VM (even - # with WLR_RENDERER_ALLOW_SOFTWARE): - # "WLR_RENDERER_ALLOW_SOFTWARE" = "1"; - "WLR_RENDERER" = "pixman"; - }; - - # To help with OCR: - etc."xdg/foot/foot.ini".text = lib.generators.toINI { } { - main = { - font = "inconsolata:size=14"; - }; - colors = rec { - foreground = "000000"; - background = "ffffff"; - regular2 = foreground; - }; - }; - }; - - fonts.fonts = [ pkgs.inconsolata ]; - - # Need to switch to a different GPU driver than the default one (-vga std) so that Sway can launch: - virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ]; - virtualisation.cores = 4; - virtualisation.memorySize = 2048; - }; - - enableOCR = true; - - testScript = '' - import shlex - def swaymsg(command: str, succeed=True): - with machine.nested(f"sending swaymsg {command!r}" + " (allowed to fail)" * (not succeed)): - (machine.succeed if succeed else machine.execute)( - f"su - pub-solar -c {shlex.quote('swaymsg -- ' + command)}" - ) - - - machine.wait_for_unit("multi-user.target") - - # To check the version: - print(machine.succeed("sway --version")) - - # Wait for Sway to complete startup: - machine.wait_for_file("/run/user/1000/wayland-1") - machine.wait_for_file("/tmp/sway-ipc.sock") - - # Start a terminal (foot) on workspace 3: - machine.wait_for_text("1") - machine.send_key("meta_l-3") - machine.sleep(3) - machine.send_key("meta_l-ret") - machine.sleep(10) - machine.send_chars("whoami\n") - machine.sleep(3) - machine.wait_for_text("pub-solar") - machine.send_chars("test-wayland\n") - machine.wait_for_file("/tmp/test-wayland-exit-ok") - print(machine.succeed("cat /tmp/test-wayland.out")) - machine.copy_from_vm("/tmp/test-wayland.out") - machine.sleep(3) - machine.screenshot("foot_wayland_info") - machine.send_key("meta_l-shift-q") - machine.wait_until_fails("pgrep foot") - ''; -} diff --git a/tests/second-test.nix b/tests/second-test.nix deleted file mode 100644 index d6409820..00000000 --- a/tests/second-test.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ }: -{ - name = "secondTest"; - - nodes.test-machine2 = { suites ? null, ... }: { - imports = [ - suites.iso - ]; - }; - - testScript = '' - machines[0].systemctl("is-system-running --wait") - ''; -}