From 50a538c78ec3f71a37bfc9416565b11aeb105c54 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Sep 2022 04:01:45 +0000 Subject: [PATCH 001/391] start generator work --- flake.lock | 37 +++++++++++++++++++++++++++++++++++++ flake.nix | 20 +++++++++++++++++--- generators/aws.nix | 19 +++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 generators/aws.nix diff --git a/flake.lock b/flake.lock index a3a0bac..202ceab 100644 --- a/flake.lock +++ b/flake.lock @@ -74,6 +74,42 @@ "type": "github" } }, + "nixlib": { + "locked": { + "lastModified": 1636849918, + "narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660727616, + "narHash": "sha256-zYTIvdPMYMx/EYqXODAwIIU30RiEHqNHdgarIHuEYZc=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "adccd191a0e83039d537e021f19495b7bad546a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1663357389, @@ -124,6 +160,7 @@ "inputs": { "darwin": "darwin", "home-manager": "home-manager", + "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs", "nur": "nur", "wallpapers": "wallpapers", diff --git a/flake.nix b/flake.nix index 6ba3749..4b95a7c 100644 --- a/flake.nix +++ b/flake.nix @@ -32,9 +32,15 @@ flake = false; }; + # Used to generate NixOS images for other platforms + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; - outputs = { self, nixpkgs, darwin, wsl, home-manager, nur, wallpapers }: + outputs = { self, nixpkgs, ... }@inputs: let @@ -57,14 +63,14 @@ in { - nixosConfigurations = { + nixosConfigurations = with inputs; { desktop = import ./hosts/desktop { inherit nixpkgs home-manager nur globals wallpapers; }; wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; }; }; - darwinConfigurations = { + darwinConfigurations = with inputs; { macbook = import ./hosts/macbook { inherit nixpkgs darwin home-manager nur globals; }; @@ -110,6 +116,14 @@ }); + # Package servers into images with a generator + packages.x86_64-linux = with inputs; { + aws = import ./generators/aws.nix { + inherit nixpkgs nixos-generators home-manager globals; + system = "x86_64-linux"; + }; + }; + # Templates for starting other projects quickly templates = rec { default = basic; diff --git a/generators/aws.nix b/generators/aws.nix new file mode 100644 index 0000000..f1f54cd --- /dev/null +++ b/generators/aws.nix @@ -0,0 +1,19 @@ +{ nixpkgs, system, nixos-generators, home-manager, globals, ... }: + +nixos-generators.nixoGenerate { + inherit system; + imports = [ + globals + home-manager.nixosModules.home-manager + { + networking.hostName = "sheep"; + gui.enable = false; + colorscheme = (import ../../modules/colorscheme/gruvbox); + passwordHash = + "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + } + ../hosts/common.nix + ../modules/nixos + ]; + format = "aws"; +} From 9e3345ff9bfa7142eb11936fb794f3816a5ab8fa Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Sep 2022 11:50:45 +0000 Subject: [PATCH 002/391] add sshd for aws generators --- generators/aws.nix | 3 +++ modules/services/sshd.nix | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 modules/services/sshd.nix diff --git a/generators/aws.nix b/generators/aws.nix index f1f54cd..0c7997c 100644 --- a/generators/aws.nix +++ b/generators/aws.nix @@ -11,9 +11,12 @@ nixos-generators.nixoGenerate { colorscheme = (import ../../modules/colorscheme/gruvbox); passwordHash = "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; } ../hosts/common.nix ../modules/nixos + ../modules/services/sshd.nix ]; format = "aws"; } diff --git a/modules/services/sshd.nix b/modules/services/sshd.nix new file mode 100644 index 0000000..8be395b --- /dev/null +++ b/modules/services/sshd.nix @@ -0,0 +1,24 @@ +{ config, pkgs, lib, ... }: { + + options = { + publicKey = lib.mkOption { + type = lib.types.str; + description = "Public SSH key authorized for this system."; + }; + }; + + config = { + services.openssh = { + enable = true; + ports = [ 22 ]; + passwordAuthentication = false; + gatewayPorts = "no"; + forwardX11 = false; + allowSFTP = true; + permitRootLogin = "no"; + }; + + users.users.${config.user}.authorizedKeys.keys = [ config.publicKey ]; + }; + +} From 720a3cc409ee16185be14c69709ab5e10c803086 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Sep 2022 12:50:04 +0000 Subject: [PATCH 003/391] additional options needed to build aws image --- generators/aws.nix | 19 ++++++++++++++----- modules/services/sshd.nix | 10 ++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/generators/aws.nix b/generators/aws.nix index 0c7997c..f648c18 100644 --- a/generators/aws.nix +++ b/generators/aws.nix @@ -1,22 +1,31 @@ { nixpkgs, system, nixos-generators, home-manager, globals, ... }: -nixos-generators.nixoGenerate { +nixos-generators.nixosGenerate { inherit system; - imports = [ - globals + format = "amazon"; + modules = [ home-manager.nixosModules.home-manager { + user = globals.user; + fullName = globals.fullName; + dotfilesRepo = globals.dotfilesRepo; + gitName = globals.gitName; + gitEmail = globals.gitEmail; networking.hostName = "sheep"; gui.enable = false; - colorscheme = (import ../../modules/colorscheme/gruvbox); + colorscheme = (import ../modules/colorscheme/gruvbox); passwordHash = "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + # AWS settings require this + permitRootLogin = "prohibit-password"; } ../hosts/common.nix ../modules/nixos ../modules/services/sshd.nix + ] ++ [ + # Required to fix diskSize errors during build + ({ ... }: { amazonImage.sizeMB = 16 * 1024; }) ]; - format = "aws"; } diff --git a/modules/services/sshd.nix b/modules/services/sshd.nix index 8be395b..0161aba 100644 --- a/modules/services/sshd.nix +++ b/modules/services/sshd.nix @@ -5,6 +5,11 @@ type = lib.types.str; description = "Public SSH key authorized for this system."; }; + permitRootLogin = lib.mkOption { + type = lib.types.str; + description = "Root login settings."; + default = "no"; + }; }; config = { @@ -15,10 +20,11 @@ gatewayPorts = "no"; forwardX11 = false; allowSFTP = true; - permitRootLogin = "no"; + permitRootLogin = config.permitRootLogin; }; - users.users.${config.user}.authorizedKeys.keys = [ config.publicKey ]; + users.users.${config.user}.openssh.authorizedKeys.keys = + [ config.publicKey ]; }; } From f834cc20f4ae772d81ede8142d6f67603d6b0952 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 21 Sep 2022 03:49:04 +0000 Subject: [PATCH 004/391] aws generator gh workflow and terraform upload --- flake.nix | 2 +- generators/{aws.nix => aws/default.nix} | 0 generators/aws/main.tf | 80 ++++++++ generators/aws/workflow.yml | 260 ++++++++++++++++++++++++ 4 files changed, 341 insertions(+), 1 deletion(-) rename generators/{aws.nix => aws/default.nix} (100%) create mode 100644 generators/aws/main.tf create mode 100644 generators/aws/workflow.yml diff --git a/flake.nix b/flake.nix index 4b95a7c..b995b50 100644 --- a/flake.nix +++ b/flake.nix @@ -118,7 +118,7 @@ # Package servers into images with a generator packages.x86_64-linux = with inputs; { - aws = import ./generators/aws.nix { + aws = import ./generators/aws { inherit nixpkgs nixos-generators home-manager globals; system = "x86_64-linux"; }; diff --git a/generators/aws.nix b/generators/aws/default.nix similarity index 100% rename from generators/aws.nix rename to generators/aws/default.nix diff --git a/generators/aws/main.tf b/generators/aws/main.tf new file mode 100644 index 0000000..4fbb2ca --- /dev/null +++ b/generators/aws/main.tf @@ -0,0 +1,80 @@ +locals { + image_file = one(fileset(path.root, "result/nixos-amazon-image-*.vhd")) +} + +# Upload to S3 +resource "aws_s3_object" "image" { + bucket = "your_bucket_name" + key = basename(local.image_file) + source = local.image_file + etag = filemd5(local.image_file) +} + +# Setup IAM access for the VM Importer +data "aws_iam_policy_document" "vmimport_trust_policy" { + statement { + actions = ["sts:AssumeRole"] + principals { + type = "Service" + identifiers = ["vmie.amazonaws.com"] + } + } +} + +data "aws_iam_policy_document" "vmimport" { + statement { + actions = [ + "s3:GetBucketLocation", + "s3:GetObject", + "s3:ListBucket", + ] + resources = [ + "arn:aws:s3:::${aws_s3_object.image.bucket}", + "arn:aws:s3:::${aws_s3_object.image.bucket}/*", + ] + } + statement { + actions = [ + "ec2:ModifySnapshotAttribute", + "ec2:CopySnapshot", + "ec2:RegisterImage", + "ec2:Describe*", + ] + resources = ["*"] + } +} + +resource "aws_iam_role" "vmimport" { + name = "vmimport" + assume_role_policy = data.aws_iam_policy_document.vmimport_trust_policy.json + inline_policy { + name = "vmimport" + policy = data.aws_iam_policy_document.vmimport.json + } +} + +# Import to EBS +resource "aws_ebs_snapshot_import" "image" { + disk_container { + format = "VHD" + user_bucket { + s3_bucket = aws_s3_object.image.bucket + s3_key = aws_s3_object.image.key + } + } + + role_name = aws_iam_role.vmimport.name +} + +# Convert to AMI +resource "aws_ami" "image" { + description = "Created with NixOS." + name = replace(basename(local.image_file), "/\\.vhd$/", "") + virtualization_type = "hvm" + + ebs_block_device { + device_name = "/dev/xvda" + snapshot_id = aws_ebs_snapshot_import.image.id + volume_size = 8 + } +} diff --git a/generators/aws/workflow.yml b/generators/aws/workflow.yml new file mode 100644 index 0000000..c0210e2 --- /dev/null +++ b/generators/aws/workflow.yml @@ -0,0 +1,260 @@ +name: 'Terraform' +env: + + + AWS_ACCOUNT_NUMBER: '' + AWS_PLAN_ROLE_NAME: github_actions_plan + AWS_APPLY_ROLE_NAME: github_actions_admin + + # Always required. Used for authenticating to AWS, but can also act as your + # default region if you don't want to specify in the provider configuration. + AWS_REGION: us-east-1 + + # You must change these to fit your project. + TF_VAR_project: change-me + TF_VAR_label: change-me + TF_VAR_owner: Your Name Here + + # If storing Terraform in a subdirectory, specify it here. + TERRAFORM_DIRECTORY: . + + # Pinned versions of tools to use. + # Check for new releases: + # - https://github.com/hashicorp/terraform/releases + # - https://github.com/fugue/regula/releases + # - https://github.com/terraform-linters/tflint/releases + TERRAFORM_VERSION: 1.2.6 + REGULA_VERSION: 2.9.0 + TFLINT_VERSION: 0.39.1 + + # Terraform configuration options + TERRAFORM_PARALLELISM: 10 + + # These variables are passed to Terraform based on GitHub information. + TF_VAR_repo: ${{ github.repository }} + +# This workflow is triggered in the following ways. +on: + + # Any push or merge to these branches. + push: + branches: + - dev + - prod + + # Any pull request targeting these branches (plan only). + pull_request: + branches: + - dev + - prod + + + # Any manual trigger on these branches. + workflow_dispatch: + branches: + - dev + - prod + +# ------------------------------------------------------------------- +# The rest of this workflow can operate without adjustments. Edit the +# below content at your own risk! +# ------------------------------------------------------------------- + +# Used to connect to AWS IAM +permissions: + id-token: write + contents: read + pull-requests: write + +# Only run one workflow at a time for each Terraform state. This prevents +# lockfile conflicts, especially during PR vs push. +concurrency: terraform-${{ github.base_ref || github.ref }} + +jobs: + terraform: + + name: 'Terraform' + + # Change this if you need to run your deployment on-prem. + runs-on: ubuntu-latest + + steps: + + # Downloads the current repo code to the runner. + - name: Checkout Repo Code + uses: actions/checkout@v2 + + # Install Nix + - name: Install Nix + uses: cachix/install-nix-action@v17 + + # Build the image + - name: Build Image + run: nix build .#aws + + # Login to AWS + - name: AWS Assume Role + uses: aws-actions/configure-aws-credentials@v1.6.1 + with: + role-to-assume: ${{ env.AWS_ROLE_ARN }} + aws-region: ${{ env.AWS_REGION }} + + # Exports all GitHub Secrets as environment variables prefixed by + # "TF_VAR_", which exposes them to Terraform. The name of each GitHub + # Secret must match its Terraform variable name exactly. + - name: Export Secrets to Terraform Variables + env: + ALL_SECRETS: ${{ toJson(secrets) }} + run: | + echo "$ALL_SECRETS" \ + | jq "to_entries | .[] | \"TF_VAR_\" + ( .key | ascii_downcase ) + \"=\" + .value" \ + | tr -d \" >> $GITHUB_ENV + + # Installs the Terraform binary and some other accessory functions. + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: ${{ env.TERRAFORM_VERSION }} + + # Checks whether Terraform is formatted properly. If this fails, you + # should install the pre-commit hook. + - name: Check Formatting + run: | + terraform fmt -no-color -check -diff -recursive + + # Downloads a Terraform code lint test. + - uses: terraform-linters/setup-tflint@v1 + name: Setup TFLint + with: + tflint_version: v${{ env.TFLINT_VERSION }} + + # Sets up linting with this codebase. + - name: Init TFLint + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: tflint --init + + # Lints the current code. + - name: Run TFLint + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + tflint -f compact + find ./modules/* -type d -maxdepth 0 | xargs -I __ tflint -f compact --disable-rule=terraform_required_providers --disable-rule=terraform_required_version __ + + # Connects to remote state backend and download providers. + - name: Terraform Init + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + terraform init \ + -backend-config="role_arn=${{ env.AWS_STATE_ROLE_ARN }}" \ + -backend-config="region=us-east-1" \ + -backend-config="workspace_key_prefix=accounts/${{ env.AWS_ACCOUNT_NUMBER }}/${{ github.repository }}" \ + -backend-config="key=state.tfstate" \ + -backend-config="dynamodb_table=global-tf-state-lock" + + # Set the Terraform Workspace to the current branch name. + - name: Set Terraform Workspace + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + shell: bash + run: | + export WORKSPACE=${{ github.base_ref || github.ref_name }} + terraform workspace select ${WORKSPACE} || terraform workspace new $WORKSPACE + echo "TF_WORKSPACE=$(echo ${WORKSPACE} | sed 's/\//_/g')" >> $GITHUB_ENV + + # Checks differences between current code and infrastructure state. + - name: Terraform Plan + id: plan + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + terraform plan \ + -input=false \ + -no-color \ + -out=tfplan \ + -parallelism=${TERRAFORM_PARALLELISM} \ + -var-file=variables-${TF_WORKSPACE}.tfvars + + # Gets the results of the plan for pull requests. + - name: Terraform Show Plan + id: show + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: terraform show -no-color tfplan + + # Adds the results of the plan to the pull request. + - name: Comment Plan + uses: actions/github-script@v6 + if: github.event_name == 'pull_request' + env: + STDOUT: "```terraform\n${{ steps.show.outputs.stdout }}```" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // 1. Retrieve existing bot comments for the PR + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }) + const botComment = comments.find(comment => { + return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style') + }) + + // 2. Prepare format of the comment + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` +
Validation Output + + \`\`\`\n + ${{ steps.validate.outputs.stdout }} + \`\`\` + +
+ + #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` + +
Show Plan + + \`\`\`\n + ${process.env.PLAN} + \`\`\` + +
+ + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; + + // 3. If we have a comment, update it, otherwise create a new one + if (botComment) { + github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: output + }) + } else { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: output + }) + } + + # Downloads Regula and checks whether the plan meets compliance requirements. + - name: Regula Compliance Check + shell: bash + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + REGULA_URL="https://github.com/fugue/regula/releases/download/v${REGULA_VERSION}/regula_${REGULA_VERSION}_Linux_x86_64.tar.gz" + curl -sL "$REGULA_URL" -o regula.tar.gz + tar xzf regula.tar.gz + terraform show -json tfplan | ./regula run + + # Deploys infrastructure or changes to infrastructure. + - name: Terraform Apply + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + run: | + terraform apply \ + -auto-approve \ + -input=false \ + -parallelism=${TERRAFORM_PARALLELISM} \ + tfplan From 4e23d677e8e5d00e7be832aed0460b6363507e94 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 30 Sep 2022 10:11:55 -0400 Subject: [PATCH 005/391] auto-formatting changes --- hosts/common.nix | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/hosts/common.nix b/hosts/common.nix index e50cd98..2217f62 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -55,31 +55,33 @@ }; }; - config = let stateVersion = "22.11"; - in { + config = + let stateVersion = "22.11"; + in + { - # Enable features in Nix commands - nix.extraOptions = "experimental-features = nix-command flakes"; + # Enable features in Nix commands + nix.extraOptions = "experimental-features = nix-command flakes"; - # Basic common system packages for all devices - environment.systemPackages = with pkgs; [ git vim wget curl ]; + # Basic common system packages for all devices + environment.systemPackages = with pkgs; [ git vim wget curl ]; - # Use the system-level nixpkgs instead of Home Manager's - home-manager.useGlobalPkgs = true; + # Use the system-level nixpkgs instead of Home Manager's + home-manager.useGlobalPkgs = true; - # Install packages to /etc/profiles instead of ~/.nix-profile, useful when - # using multiple profiles for one user - home-manager.useUserPackages = true; + # Install packages to /etc/profiles instead of ~/.nix-profile, useful when + # using multiple profiles for one user + home-manager.useUserPackages = true; - # Allow specified unfree packages (identified elsewhere) - # Retrieves package object based on string name - nixpkgs.config.allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) config.unfreePackages; + # Allow specified unfree packages (identified elsewhere) + # Retrieves package object based on string name + nixpkgs.config.allowUnfreePredicate = pkg: + builtins.elem (lib.getName pkg) config.unfreePackages; - # Pin a state version to prevent warnings - home-manager.users.${config.user}.home.stateVersion = stateVersion; - home-manager.users.root.home.stateVersion = stateVersion; + # Pin a state version to prevent warnings + home-manager.users.${config.user}.home.stateVersion = stateVersion; + home-manager.users.root.home.stateVersion = stateVersion; - }; + }; } From 657bec0929b0f01bd27a2f52b8e3ea48e452653d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 30 Sep 2022 11:09:58 -0400 Subject: [PATCH 006/391] browse active directory on macos --- modules/darwin/homebrew.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 3621f3e..b6ffb64 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -29,17 +29,19 @@ ]; brews = [ "trash" # Delete files and folders to trash instead of rm + "openjdk" # Required by Apache Directory Studio ]; casks = [ - "firefox" # Firefox packaging on Nix is broken for MacOS - "1password" # 1Password packaging on Nix is broken for MacOS + "firefox" # Firefox packaging on Nix is broken for macOS + "1password" # 1Password packaging on Nix is broken for macOS "scroll-reverser" # Different scroll style for mouse vs. trackpad "meetingbar" # Show meetings in menu bar "gitify" # Git notifications in menu bar "logitech-g-hub" # Mouse and keyboard management "mimestream" # Gmail client - "obsidian" # Obsidian packaging on Nix is not available for MacOS + "obsidian" # Obsidian packaging on Nix is not available for macOS "steam" # Not packaged for Nix + "apache-directory-studio" # Packaging on Nix is not available for macOS ]; }; From d303924f02ef13db84869ac4faeee6f8f4fe09a3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 16:21:34 +0000 Subject: [PATCH 007/391] try adding oracle server config --- flake.nix | 2 ++ hosts/{server => oracle}/default.nix | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) rename hosts/{server => oracle}/default.nix (58%) diff --git a/flake.nix b/flake.nix index 7fd9403..ccd824a 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,8 @@ inherit nixpkgs home-manager nur globals wallpapers; }; wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; }; + oracle = + import ./hosts/oracle { inherit nixpkgs home-manager globals; }; }; darwinConfigurations = with inputs; { diff --git a/hosts/server/default.nix b/hosts/oracle/default.nix similarity index 58% rename from hosts/server/default.nix rename to hosts/oracle/default.nix index fad1431..fd90dc3 100644 --- a/hosts/server/default.nix +++ b/hosts/oracle/default.nix @@ -1,20 +1,23 @@ { nixpkgs, home-manager, globals, ... }: -# System configuration for a generic server +# System configuration for an Oracle free server nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; + system = "aarch64-linux"; specialArgs = { }; modules = [ - globals + (removeAttrs globals [ "mailServer" ]) home-manager.nixosModules.home-manager { - networking.hostName = "sheep"; + networking.hostName = "oracle"; gui.enable = false; colorscheme = (import ../../modules/colorscheme/gruvbox); passwordHash = "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; } ../common.nix ../../modules/nixos + ../../modules/services/sshd.nix ]; } From 3ec1ef4394eb3789d49d8fb510e209237310bf16 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 16:24:44 +0000 Subject: [PATCH 008/391] add server bootloader --- hosts/oracle/default.nix | 1 + modules/hardware/server.nix | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 modules/hardware/server.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index fd90dc3..47d0e50 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -18,6 +18,7 @@ nixpkgs.lib.nixosSystem { } ../common.nix ../../modules/nixos + ../../modules/hardware/server.nix ../../modules/services/sshd.nix ]; } diff --git a/modules/hardware/server.nix b/modules/hardware/server.nix new file mode 100644 index 0000000..7647b8e --- /dev/null +++ b/modules/hardware/server.nix @@ -0,0 +1,7 @@ +{ config, ... }: { + + # Servers need a bootloader or they won't start + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + +} From 381e06519b13daf56086e5c9727e31b33d2fa3a4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 16:29:16 +0000 Subject: [PATCH 009/391] add oracle hardware config --- hosts/oracle/default.nix | 1 + hosts/oracle/hardware-configuration.nix | 34 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 hosts/oracle/hardware-configuration.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 47d0e50..c9ab134 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -16,6 +16,7 @@ nixpkgs.lib.nixosSystem { publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; } + ./hardware-configuration.nix ../common.nix ../../modules/nixos ../../modules/hardware/server.nix diff --git a/hosts/oracle/hardware-configuration.nix b/hosts/oracle/hardware-configuration.nix new file mode 100644 index 0000000..ef1e850 --- /dev/null +++ b/hosts/oracle/hardware-configuration.nix @@ -0,0 +1,34 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/e1b6bd50-306d-429a-9f45-78f57bc597c3"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/D5CA-237A"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eth0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; +} From f20b4ee31aafa495f078ddabd9342a461c23c87e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 18:24:06 +0000 Subject: [PATCH 010/391] add ssh host to starship --- modules/shell/starship.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/shell/starship.nix b/modules/shell/starship.nix index 3e9443c..7fcfea6 100644 --- a/modules/shell/starship.nix +++ b/modules/shell/starship.nix @@ -9,6 +9,7 @@ "$git_branch" "$git_commit" "$git_status" + "$hostname" "$cmd_duration" "$character" ]; @@ -47,6 +48,10 @@ deleted = "✘"; style = "red"; }; + hostname = { + ssh_only = true; + format = "on [$hostname](bold red) "; + }; nix_shell = { format = "[$symbol $name]($style)"; symbol = "❄️"; From cd53060f0237a770d2acb7f4185640c0caaa6a40 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 18:28:03 +0000 Subject: [PATCH 011/391] switch to ssh for dotfiles repo --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ccd824a..3b1fac4 100644 --- a/flake.nix +++ b/flake.nix @@ -51,7 +51,7 @@ gitName = fullName; gitEmail = "7386960+nmasur@users.noreply.github.com"; mailServer = "noahmasur.com"; - dotfilesRepo = "https://github.com/nmasur/dotfiles"; + dotfilesRepo = "git@github.com:nmasur/dotfiles"; }; # System types to support. From 034ff33e70624d3af114e4c901a30e1f6521f124 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 18:28:32 +0000 Subject: [PATCH 012/391] add more description for mkpasswd salt --- modules/nixos/user.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix index 9d42048..dd5b2bd 100644 --- a/modules/nixos/user.nix +++ b/modules/nixos/user.nix @@ -5,6 +5,7 @@ passwordHash = lib.mkOption { type = lib.types.str; description = "Password created with mkpasswd -m sha-512"; + # Test it by running: mkpasswd -m sha-512 --salt "PZYiMGmJIIHAepTM" }; }; From db0645075f91c3d31cc952fbad871dc3e8cae812 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 21:39:36 +0000 Subject: [PATCH 013/391] setup calibre server --- hosts/oracle/default.nix | 1 + modules/services/calibre.nix | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 modules/services/calibre.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index c9ab134..2d1ce42 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -21,5 +21,6 @@ nixpkgs.lib.nixosSystem { ../../modules/nixos ../../modules/hardware/server.nix ../../modules/services/sshd.nix + ../../modules/services/calibre.nix ]; } diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix new file mode 100644 index 0000000..4d5dbf9 --- /dev/null +++ b/modules/services/calibre.nix @@ -0,0 +1,41 @@ +{ config, pkgs, lib, ... }: + +let + + libraryPath = "${config.homePath}/media/books"; + +in { + + options = { }; + + config = { + services.calibre-server = { + enable = true; + libraries = [ libraryPath ]; + }; + + services.calibre-web = { + enable = true; + openFirewall = true; + options = { + reverseProxyAuth.enable = false; + enableBookConversion = true; + }; + }; + + home-manager.users.${config.user}.home.activation = { + + # Always create library directory if it doesn't exist + calibreLibrary = + config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' + if [ ! -d "${libraryPath}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath} + fi + ''; + + }; + + }; + +} From 015c393274fddb28f0500993f61f623f9834d515 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 21:42:33 +0000 Subject: [PATCH 014/391] docs: deprecated nixFlakes package --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9387107..cc3c7a5 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ installer disk: ```bash lsblk # Choose the disk you want to wipe -nix-shell -p nixFlakes +nix-shell -p nixVersions.stable nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop ``` @@ -35,7 +35,7 @@ If you're already running NixOS, you can switch to this configuration with the following command: ```bash -nix-shell -p nixFlakes +nix-shell -p nixVersions.stable sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop ``` @@ -46,7 +46,7 @@ WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to the WSL configuration: ``` -nix-shell -p nixFlakes +nix-shell -p nixVersions.stable sudo nixos-rebuild switch --flake github:nmasur/dotfiles#wsl ``` From 8a97d9b2da59d5e7dadc66014c8c2dba554f73a9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Oct 2022 02:47:10 +0000 Subject: [PATCH 015/391] calibre needs to use path it can read --- modules/services/calibre.nix | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 4d5dbf9..bf7009d 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -2,7 +2,7 @@ let - libraryPath = "${config.homePath}/media/books"; + libraryPath = "/var/lib/calibre-server"; in { @@ -23,19 +23,6 @@ in { }; }; - home-manager.users.${config.user}.home.activation = { - - # Always create library directory if it doesn't exist - calibreLibrary = - config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - if [ ! -d "${libraryPath}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath} - fi - ''; - - }; - }; } From 19de5834338cbb7f6b6dfad86a15f7834fbb23f4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Oct 2022 14:48:51 +0000 Subject: [PATCH 016/391] setup caddy and calibre-web --- hosts/oracle/default.nix | 4 +-- modules/nixos/user.nix | 2 +- modules/services/calibre.nix | 52 +++++++++++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 2d1ce42..b267dc2 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -9,10 +9,10 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager { networking.hostName = "oracle"; + bookServer = "books.masu.rs"; gui.enable = false; colorscheme = (import ../../modules/colorscheme/gruvbox); - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; } diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix index dd5b2bd..24d0ff8 100644 --- a/modules/nixos/user.nix +++ b/modules/nixos/user.nix @@ -3,7 +3,7 @@ options = { passwordHash = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Password created with mkpasswd -m sha-512"; # Test it by running: mkpasswd -m sha-512 --salt "PZYiMGmJIIHAepTM" }; diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index bf7009d..9ca3838 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -2,27 +2,67 @@ let - libraryPath = "/var/lib/calibre-server"; + # Must set group owner to calibre-web + libraryPath = "/var/books"; in { - options = { }; + options = { + bookServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for Calibre library"; + }; + }; config = { - services.calibre-server = { - enable = true; - libraries = [ libraryPath ]; - }; services.calibre-web = { enable = true; openFirewall = true; options = { + calibreLibrary = libraryPath; reverseProxyAuth.enable = false; enableBookConversion = true; }; }; + services.caddy = { + enable = true; + adapter = "''"; # Required to enable JSON + configFile = pkgs.writeText "Caddyfile" (builtins.toJSON { + apps.http.servers = { + calibre = { + listen = [ ":443" ]; + routes = [{ + match = [{ host = [ config.bookServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8083"; }]; + headers.request.add."X-Script-Name" = [ "/calibre-web" ]; + }]; + }]; + }; + }; + }); + + }; + + networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; }; + + # Create directory and set permissions + system.activationScripts.calibreLibrary.text = '' + if [ ! -d "${libraryPath}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath} + fi + if [ ! "$(stat -c "%G" ${libraryPath})" = "calibre-web" ]; then + $DRY_RUN_CMD chown $VERBOSE_ARG -R calibre-web:calibre-web ${libraryPath} + fi + if [ ! "$(stat -c "%a" ${libraryPath})" = "775" ]; then + $DRY_RUN_CMD chmod $VERBOSE_ARG 0775 ${libraryPath} + $DRY_RUN_CMD chmod $VERBOSE_ARG -R 0640 ${libraryPath}/* + fi + ''; + }; } From 90bc2ecd49f0e3f7a77aaf9a46b9aac108a4488b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Oct 2022 15:09:54 +0000 Subject: [PATCH 017/391] add iptables settings for oracle reboot --- hosts/oracle/default.nix | 1 + modules/services/oracle.nix | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 modules/services/oracle.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index b267dc2..e8dd31f 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -20,6 +20,7 @@ nixpkgs.lib.nixosSystem { ../common.nix ../../modules/nixos ../../modules/hardware/server.nix + ../../modules/services/oracle.nix ../../modules/services/sshd.nix ../../modules/services/calibre.nix ]; diff --git a/modules/services/oracle.nix b/modules/services/oracle.nix new file mode 100644 index 0000000..99cee98 --- /dev/null +++ b/modules/services/oracle.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + + # Needs to be run at boot for Oracle firewall + systemd.services.openIpTables = { + script = "${pkgs.iptables}/bin/iptables -I INPUT -j ACCEPT"; + wantedBy = [ "multi-user.target" ]; + }; + +} From b4ba0706c0c94e2a9b3153b132fa3b230df5b823 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Oct 2022 15:24:25 +0000 Subject: [PATCH 018/391] move caddy config into separate file --- modules/services/caddy.nix | 26 ++++++++++++++++++++++++++ modules/services/calibre.nix | 31 ++++++++++++------------------- 2 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 modules/services/caddy.nix diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix new file mode 100644 index 0000000..d788fc1 --- /dev/null +++ b/modules/services/caddy.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +let + +in { + + options = { + caddyServers = lib.mkOption { + type = lib.types.attrs; + description = "Caddy JSON configs for http servers"; + }; + }; + + config = { + + services.caddy = { + enable = true; + adapter = "''"; # Required to enable JSON + configFile = pkgs.writeText "Caddyfile" + (builtins.toJSON { apps.http.servers = config.caddyServers; }); + + }; + + }; + +} diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 9ca3838..83b4725 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -7,6 +7,8 @@ let in { + imports = [ ./caddy.nix ]; + options = { bookServer = lib.mkOption { type = lib.types.str; @@ -26,25 +28,16 @@ in { }; }; - services.caddy = { - enable = true; - adapter = "''"; # Required to enable JSON - configFile = pkgs.writeText "Caddyfile" (builtins.toJSON { - apps.http.servers = { - calibre = { - listen = [ ":443" ]; - routes = [{ - match = [{ host = [ config.bookServer ]; }]; - handle = [{ - handler = "reverse_proxy"; - upstreams = [{ dial = "localhost:8083"; }]; - headers.request.add."X-Script-Name" = [ "/calibre-web" ]; - }]; - }]; - }; - }; - }); - + caddyServers.calibre = { + listen = [ ":443" ]; + routes = [{ + match = [{ host = [ config.bookServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8083"; }]; + headers.request.add."X-Script-Name" = [ "/calibre-web" ]; + }]; + }]; }; networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; }; From f196f546b8de6bc9fc1982ba7e1156f24bad841e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Oct 2022 17:40:10 +0000 Subject: [PATCH 019/391] add jellyfin, switch caddy to one listener --- hosts/oracle/default.nix | 2 ++ modules/services/caddy.nix | 14 +++++++++----- modules/services/calibre.nix | 17 +++++++---------- modules/services/jellyfin.nix | 23 +++++++++++++++++++++++ 4 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 modules/services/jellyfin.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index e8dd31f..62cf364 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -10,6 +10,7 @@ nixpkgs.lib.nixosSystem { { networking.hostName = "oracle"; bookServer = "books.masu.rs"; + streamServer = "stream.masu.rs"; gui.enable = false; colorscheme = (import ../../modules/colorscheme/gruvbox); passwordHash = null; @@ -23,5 +24,6 @@ nixpkgs.lib.nixosSystem { ../../modules/services/oracle.nix ../../modules/services/sshd.nix ../../modules/services/calibre.nix + ../../modules/services/jellyfin.nix ]; } diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix index d788fc1..eec26cc 100644 --- a/modules/services/caddy.nix +++ b/modules/services/caddy.nix @@ -5,9 +5,9 @@ let in { options = { - caddyServers = lib.mkOption { - type = lib.types.attrs; - description = "Caddy JSON configs for http servers"; + caddyRoutes = lib.mkOption { + type = lib.types.listOf lib.types.attrs; + description = "Caddy JSON routes for http servers"; }; }; @@ -16,8 +16,12 @@ in { services.caddy = { enable = true; adapter = "''"; # Required to enable JSON - configFile = pkgs.writeText "Caddyfile" - (builtins.toJSON { apps.http.servers = config.caddyServers; }); + configFile = pkgs.writeText "Caddyfile" (builtins.toJSON { + apps.http.servers.main = { + listen = [ ":443" ]; + routes = config.caddyRoutes; + }; + }); }; diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 83b4725..38b794c 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -28,17 +28,14 @@ in { }; }; - caddyServers.calibre = { - listen = [ ":443" ]; - routes = [{ - match = [{ host = [ config.bookServer ]; }]; - handle = [{ - handler = "reverse_proxy"; - upstreams = [{ dial = "localhost:8083"; }]; - headers.request.add."X-Script-Name" = [ "/calibre-web" ]; - }]; + caddyRoutes = [{ + match = [{ host = [ config.bookServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8083"; }]; + headers.request.add."X-Script-Name" = [ "/calibre-web" ]; }]; - }; + }]; networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; }; diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix new file mode 100644 index 0000000..c866cc0 --- /dev/null +++ b/modules/services/jellyfin.nix @@ -0,0 +1,23 @@ +{ config, lib, ... }: { + + options = { + streamServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for Jellyfin library"; + }; + }; + + config = { + + services.jellyfin.enable = true; + + caddyRoutes = [{ + match = [{ host = [ config.streamServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8096"; }]; + }]; + }]; + }; + +} From 2434376963845ac00e8836ab2d875068133fcd5f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Oct 2022 20:54:26 +0000 Subject: [PATCH 020/391] working nextcloud configuration --- apps/loadkey.nix | 9 +++ flake.nix | 3 + hosts/oracle/default.nix | 7 +++ modules/services/nextcloud.nix | 98 +++++++++++++++++++++++++++++++++ private/nextcloud-s3.age | 6 ++ private/nextcloud.age | Bin 0 -> 246 bytes 6 files changed, 123 insertions(+) create mode 100644 apps/loadkey.nix create mode 100644 modules/services/nextcloud.nix create mode 100644 private/nextcloud-s3.age create mode 100644 private/nextcloud.age diff --git a/apps/loadkey.nix b/apps/loadkey.nix new file mode 100644 index 0000000..c02de30 --- /dev/null +++ b/apps/loadkey.nix @@ -0,0 +1,9 @@ +{ globals, pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "loadkey" '' + ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 + ''); + +} diff --git a/flake.nix b/flake.nix index 3b1fac4..d1aff1c 100644 --- a/flake.nix +++ b/flake.nix @@ -89,6 +89,9 @@ # Display the readme for this repository readme = import ./apps/readme.nix { inherit pkgs; }; + # Load the SSH key for this machine + loadkey = import ./apps/loadkey.nix { inherit pkgs; }; + }); devShells = forAllSystems (system: diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 62cf364..0af38e9 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -11,11 +11,17 @@ nixpkgs.lib.nixosSystem { networking.hostName = "oracle"; bookServer = "books.masu.rs"; streamServer = "stream.masu.rs"; + nextcloudServer = "cloud.masu.rs"; gui.enable = false; colorscheme = (import ../../modules/colorscheme/gruvbox); passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + nextcloudS3 = { + bucket = "noahmasur-nextcloud"; + hostname = "s3.us-west-002.backblazeb2.com"; + key = "0026b0e73b2e2c80000000003"; + }; } ./hardware-configuration.nix ../common.nix @@ -25,5 +31,6 @@ nixpkgs.lib.nixosSystem { ../../modules/services/sshd.nix ../../modules/services/calibre.nix ../../modules/services/jellyfin.nix + ../../modules/services/nextcloud.nix ]; } diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix new file mode 100644 index 0000000..415a8c7 --- /dev/null +++ b/modules/services/nextcloud.nix @@ -0,0 +1,98 @@ +{ config, pkgs, lib, ... }: + +let + adminpassFile = "/var/lib/nextcloud/creds"; + s3SecretFile = "/var/lib/nextcloud/creds-s3"; + +in { + + options = { + + nextcloudServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for Nextcloud"; + }; + + nextcloudS3 = { + bucket = lib.mkOption { + type = lib.types.str; + description = "S3 bucket name for Nextcloud storage"; + }; + hostname = lib.mkOption { + type = lib.types.str; + description = "S3 endpoint for Nextcloud storage"; + }; + key = lib.mkOption { + type = lib.types.str; + description = "S3 access key for Nextcloud storage"; + }; + }; + }; + + config = { + + services.nextcloud = { + enable = true; + package = pkgs.nextcloud24; # Required to specify + https = true; + hostName = "localhost"; + config = { + adminpassFile = adminpassFile; + extraTrustedDomains = [ config.nextcloudServer ]; + objectstore.s3 = { + enable = true; + bucket = config.nextcloudS3.bucket; + hostname = config.nextcloudS3.hostname; + key = config.nextcloudS3.key; + autocreate = false; + secretFile = s3SecretFile; + }; + }; + }; + + # Don't let Nginx use main ports (using Caddy instead) + services.nginx.virtualHosts."localhost".listen = [{ + addr = "127.0.0.1"; + port = 8080; + }]; + + caddyRoutes = [{ + match = [{ host = [ config.nextcloudServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8080"; }]; + }]; + }]; + + # Create credentials files + system.activationScripts.nextcloud.text = + let identityFile = "${config.homePath}/.ssh/id_ed25519"; + in '' + if [ ! -f "${identityFile}" ]; then + $DRY_RUN_CMD echo -e \nEnter the seed phrase for your SSH key...\n + $DRY_RUN_CMD echo -e \nThen press ^D when complete.\n\n + $DRY_RUN_CMD ${pkgs.melt}/bin/melt restore ${identityFile} + $DRY_RUN_CMD chown ${config.user}:wheel ${identityFile}* + $DRY_RUN_CMD echo -e \n\nContinuing activation.\n\n + fi + if [ ! -f "${adminpassFile}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname ${adminpassFile}) + $DRY_RUN_CMD ${pkgs.age}/bin/age --decrypt \ + --identity ${identityFile} \ + --output ${adminpassFile} \ + ${builtins.toString ../../private/nextcloud.age} + $DRY_RUN_CMD chown nextcloud:nextcloud ${adminpassFile} + fi + if [ ! -f "${s3SecretFile}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname ${s3SecretFile}) + $DRY_RUN_CMD ${pkgs.age}/bin/age --decrypt \ + --identity ${identityFile} \ + --output ${s3SecretFile} \ + ${builtins.toString ../../private/nextcloud-s3.age} + $DRY_RUN_CMD chown nextcloud:nextcloud ${s3SecretFile} + fi + ''; + + }; + +} diff --git a/private/nextcloud-s3.age b/private/nextcloud-s3.age new file mode 100644 index 0000000..14aad0a --- /dev/null +++ b/private/nextcloud-s3.age @@ -0,0 +1,6 @@ +age-encryption.org/v1 +-> ssh-ed25519 MgHaOw 6598vLOAPdLywyCHQtneJRWWVQhjP2ydv40ULRGLrFE +KB4O8c3bcpKkyQbjsg8Hu3m3MP5HQ90YVXy8xXHOTqk +--- mLQsxjZKwwM0jvf79WrLh1IW6mzsfuOHDYJQhjBe2Rg +ɅXLܪrױEGUP +ΖTHN$Z +L4 \ No newline at end of file diff --git a/private/nextcloud.age b/private/nextcloud.age new file mode 100644 index 0000000000000000000000000000000000000000..77526b6596398552bc8d57e1c7b76f2b79683152 GIT binary patch literal 246 zcmV_K|*h1Ge}u^GjBOeN=i{SQ)XsoI8Rr4R99_LWqK=GFii?FMNczqOJ!kG zT2(nQc~fd)bY^KwD?v7QVNyXsPi#U?LQYv@No6x-MNJAVEiE8tN^fCrQaEsHPjyo< zVp>aVNJcU?S#f%1OKNmyK|ym~%Qc(&e#L$H*Wq|4w@}KwsI6eqsKL%(O w9)AbuS8smQol&)kjaymIZ%)-gKBGgdSdg$w#39g+>lk2Ly9xs!ow8X7n=av2v;Y7A literal 0 HcmV?d00001 From 92223a49cdbc57a3038aa0cea393f9931b9d36b8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 3 Oct 2022 04:05:07 +0000 Subject: [PATCH 021/391] separate age ssh key setup from nextcloud --- modules/mail/himalaya.nix | 9 +++++---- modules/services/nextcloud.nix | 20 ++++++++------------ modules/shell/age.nix | 24 ++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 4e8963a..9fe91e0 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -72,10 +72,11 @@ }; mu.enable = false; notmuch.enable = false; - passwordCommand = - "${pkgs.age}/bin/age --decrypt --identity ${config.homePath}/.ssh/id_ed25519 ${ - builtins.toString ./mailpass.age - }"; + passwordCommand = '' + ${pkgs.age}/bin/age --decrypt \ + --identity ${config.identityFile} \ + ${builtins.toString ./mailpass.age} + ''; smtp = { host = "smtp.purelymail.com"; port = 465; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 415a8c7..39db55d 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -6,6 +6,8 @@ let in { + imports = [ ../shell/age.nix ]; + options = { nextcloudServer = lib.mkOption { @@ -65,20 +67,13 @@ in { }]; # Create credentials files - system.activationScripts.nextcloud.text = - let identityFile = "${config.homePath}/.ssh/id_ed25519"; - in '' - if [ ! -f "${identityFile}" ]; then - $DRY_RUN_CMD echo -e \nEnter the seed phrase for your SSH key...\n - $DRY_RUN_CMD echo -e \nThen press ^D when complete.\n\n - $DRY_RUN_CMD ${pkgs.melt}/bin/melt restore ${identityFile} - $DRY_RUN_CMD chown ${config.user}:wheel ${identityFile}* - $DRY_RUN_CMD echo -e \n\nContinuing activation.\n\n - fi + system.activationScripts.nextcloud = { + deps = [ "age" ]; + text = '' if [ ! -f "${adminpassFile}" ]; then $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname ${adminpassFile}) $DRY_RUN_CMD ${pkgs.age}/bin/age --decrypt \ - --identity ${identityFile} \ + --identity ${config.identityFile} \ --output ${adminpassFile} \ ${builtins.toString ../../private/nextcloud.age} $DRY_RUN_CMD chown nextcloud:nextcloud ${adminpassFile} @@ -86,12 +81,13 @@ in { if [ ! -f "${s3SecretFile}" ]; then $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname ${s3SecretFile}) $DRY_RUN_CMD ${pkgs.age}/bin/age --decrypt \ - --identity ${identityFile} \ + --identity ${config.identityFile} \ --output ${s3SecretFile} \ ${builtins.toString ../../private/nextcloud-s3.age} $DRY_RUN_CMD chown nextcloud:nextcloud ${s3SecretFile} fi ''; + }; }; diff --git a/modules/shell/age.nix b/modules/shell/age.nix index 338be8e..87cf6df 100644 --- a/modules/shell/age.nix +++ b/modules/shell/age.nix @@ -1,5 +1,25 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user}.home.packages = with pkgs; [ age ]; + options = { + identityFile = lib.mkOption { + type = lib.types.str; + description = "Path to SSH key for age"; + default = "${config.homePath}/.ssh/id_ed25519"; + }; + }; + + config = { + home-manager.users.${config.user}.home.packages = with pkgs; [ age ]; + + system.activationScripts.age.text = '' + if [ ! -f "${config.identityFile}" ]; then + $DRY_RUN_CMD echo -e \nEnter the seed phrase for your SSH key...\n + $DRY_RUN_CMD echo -e \nThen press ^D when complete.\n\n + $DRY_RUN_CMD ${pkgs.melt}/bin/melt restore ${config.identityFile} + $DRY_RUN_CMD chown ${config.user}:wheel ${config.identityFile}* + $DRY_RUN_CMD echo -e \n\nContinuing activation.\n\n + fi + ''; + }; } From a0089e28aedc1ed206956b3dbcd65e8ef23c56cf Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:12:50 +0000 Subject: [PATCH 022/391] move mailpass to private section --- modules/mail/himalaya.nix | 2 +- {modules/mail => private}/mailpass.age | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {modules/mail => private}/mailpass.age (100%) diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 9fe91e0..8e528db 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -75,7 +75,7 @@ passwordCommand = '' ${pkgs.age}/bin/age --decrypt \ --identity ${config.identityFile} \ - ${builtins.toString ./mailpass.age} + ${builtins.toString ../../private/mailpass.age} ''; smtp = { host = "smtp.purelymail.com"; diff --git a/modules/mail/mailpass.age b/private/mailpass.age similarity index 100% rename from modules/mail/mailpass.age rename to private/mailpass.age From 31f3cfe77c11e2191ed97e28ce9377186173aeee Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:19:29 +0000 Subject: [PATCH 023/391] fix firewall issues with oracle --- apps/loadkey.nix | 2 +- hosts/oracle/default.nix | 1 - modules/services/caddy.nix | 3 +++ modules/services/calibre.nix | 2 -- modules/services/oracle.nix | 9 --------- 5 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 modules/services/oracle.nix diff --git a/apps/loadkey.nix b/apps/loadkey.nix index c02de30..0b2fad1 100644 --- a/apps/loadkey.nix +++ b/apps/loadkey.nix @@ -1,4 +1,4 @@ -{ globals, pkgs, ... }: { +{ pkgs, ... }: { type = "app"; diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 0af38e9..7e0d90b 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -27,7 +27,6 @@ nixpkgs.lib.nixosSystem { ../common.nix ../../modules/nixos ../../modules/hardware/server.nix - ../../modules/services/oracle.nix ../../modules/services/sshd.nix ../../modules/services/calibre.nix ../../modules/services/jellyfin.nix diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix index eec26cc..d737f34 100644 --- a/modules/services/caddy.nix +++ b/modules/services/caddy.nix @@ -25,6 +25,9 @@ in { }; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + networking.firewall.allowedUDPPorts = [ 443 ]; + }; } diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 38b794c..b21c3de 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -37,8 +37,6 @@ in { }]; }]; - networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; }; - # Create directory and set permissions system.activationScripts.calibreLibrary.text = '' if [ ! -d "${libraryPath}" ]; then diff --git a/modules/services/oracle.nix b/modules/services/oracle.nix deleted file mode 100644 index 99cee98..0000000 --- a/modules/services/oracle.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkgs, ... }: { - - # Needs to be run at boot for Oracle firewall - systemd.services.openIpTables = { - script = "${pkgs.iptables}/bin/iptables -I INPUT -j ACCEPT"; - wantedBy = [ "multi-user.target" ]; - }; - -} From f38f782b632b55da8b7ea8b19a9f2272c35a3340 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:32:09 +0000 Subject: [PATCH 024/391] add helper statements for loadkeys app --- apps/loadkey.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/loadkey.nix b/apps/loadkey.nix index 0b2fad1..a1e03ba 100644 --- a/apps/loadkey.nix +++ b/apps/loadkey.nix @@ -3,7 +3,10 @@ type = "app"; program = builtins.toString (pkgs.writeShellScript "loadkey" '' + printf "\nEnter the seed phrase for your SSH key...\n" + printf "\nThen press ^D when complete.\n\n" ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 + printf "\n\nContinuing activation.\n\n" ''); } From 84ecbf99742b471db484214840b575c8f3d4d419 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 4 Oct 2022 00:45:05 +0000 Subject: [PATCH 025/391] grant nextcloud access to jellyfin --- hosts/oracle/default.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 7e0d90b..43cd48e 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -1,6 +1,10 @@ { nixpkgs, home-manager, globals, ... }: # System configuration for an Oracle free server + +# How to install: +# https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/ + nixpkgs.lib.nixosSystem { system = "aarch64-linux"; specialArgs = { }; @@ -8,20 +12,29 @@ nixpkgs.lib.nixosSystem { (removeAttrs globals [ "mailServer" ]) home-manager.nixosModules.home-manager { + gui.enable = false; + colorscheme = (import ../../modules/colorscheme/gruvbox); + + # FQDNs for various services networking.hostName = "oracle"; bookServer = "books.masu.rs"; streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; - gui.enable = false; - colorscheme = (import ../../modules/colorscheme/gruvbox); + + # Disable passwords, only use SSH key passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + + # Store Nextcloud data in cloud object storage nextcloudS3 = { bucket = "noahmasur-nextcloud"; hostname = "s3.us-west-002.backblazeb2.com"; key = "0026b0e73b2e2c80000000003"; }; + + # Grant access to Jellyfin directories from nextcloud + users.users.nextcloud.extraGroups = [ "jellyfin" ]; } ./hardware-configuration.nix ../common.nix From c2b570b2afe09c39d513331fa566f04085f75267 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 4 Oct 2022 03:06:55 +0000 Subject: [PATCH 026/391] don't use s3 as primary nextcloud storage --- hosts/oracle/default.nix | 7 ------- modules/services/nextcloud.nix | 36 ++-------------------------------- private/nextcloud-s3.age | 6 ------ 3 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 private/nextcloud-s3.age diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 43cd48e..8da7180 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -26,13 +26,6 @@ nixpkgs.lib.nixosSystem { publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; - # Store Nextcloud data in cloud object storage - nextcloudS3 = { - bucket = "noahmasur-nextcloud"; - hostname = "s3.us-west-002.backblazeb2.com"; - key = "0026b0e73b2e2c80000000003"; - }; - # Grant access to Jellyfin directories from nextcloud users.users.nextcloud.extraGroups = [ "jellyfin" ]; } diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 39db55d..5fad953 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -1,12 +1,10 @@ { config, pkgs, lib, ... }: -let - adminpassFile = "/var/lib/nextcloud/creds"; - s3SecretFile = "/var/lib/nextcloud/creds-s3"; +let adminpassFile = "/var/lib/nextcloud/creds"; in { - imports = [ ../shell/age.nix ]; + imports = [ ./caddy.nix ../shell/age.nix ]; options = { @@ -15,20 +13,6 @@ in { description = "Hostname for Nextcloud"; }; - nextcloudS3 = { - bucket = lib.mkOption { - type = lib.types.str; - description = "S3 bucket name for Nextcloud storage"; - }; - hostname = lib.mkOption { - type = lib.types.str; - description = "S3 endpoint for Nextcloud storage"; - }; - key = lib.mkOption { - type = lib.types.str; - description = "S3 access key for Nextcloud storage"; - }; - }; }; config = { @@ -41,14 +25,6 @@ in { config = { adminpassFile = adminpassFile; extraTrustedDomains = [ config.nextcloudServer ]; - objectstore.s3 = { - enable = true; - bucket = config.nextcloudS3.bucket; - hostname = config.nextcloudS3.hostname; - key = config.nextcloudS3.key; - autocreate = false; - secretFile = s3SecretFile; - }; }; }; @@ -78,14 +54,6 @@ in { ${builtins.toString ../../private/nextcloud.age} $DRY_RUN_CMD chown nextcloud:nextcloud ${adminpassFile} fi - if [ ! -f "${s3SecretFile}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname ${s3SecretFile}) - $DRY_RUN_CMD ${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - --output ${s3SecretFile} \ - ${builtins.toString ../../private/nextcloud-s3.age} - $DRY_RUN_CMD chown nextcloud:nextcloud ${s3SecretFile} - fi ''; }; diff --git a/private/nextcloud-s3.age b/private/nextcloud-s3.age deleted file mode 100644 index 14aad0a..0000000 --- a/private/nextcloud-s3.age +++ /dev/null @@ -1,6 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 MgHaOw 6598vLOAPdLywyCHQtneJRWWVQhjP2ydv40ULRGLrFE -KB4O8c3bcpKkyQbjsg8Hu3m3MP5HQ90YVXy8xXHOTqk ---- mLQsxjZKwwM0jvf79WrLh1IW6mzsfuOHDYJQhjBe2Rg -ɅXLܪrױEGUP -ΖTHN$Z +L4 \ No newline at end of file From a7117fe4e976f4b466ad53fea311bfc31359df4f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 4 Oct 2022 12:29:29 +0000 Subject: [PATCH 027/391] fix: max upload size for nextcloud --- modules/services/nextcloud.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 5fad953..3f14acc 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -22,6 +22,7 @@ in { package = pkgs.nextcloud24; # Required to specify https = true; hostName = "localhost"; + maxUploadSize = "50G"; config = { adminpassFile = adminpassFile; extraTrustedDomains = [ config.nextcloudServer ]; From da01f3be9b14866c331cade6da1d7b74393c2f52 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:43:04 +0000 Subject: [PATCH 028/391] add cloudflare IPs as nextcloud trusted proxies --- modules/services/nextcloud.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 3f14acc..296b352 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -26,6 +26,35 @@ in { config = { adminpassFile = adminpassFile; extraTrustedDomains = [ config.nextcloudServer ]; + trustedProxies = [ + + # Cloudflare IPv4: https://www.cloudflare.com/ips-v4 + "173.245.48.0/20" + "103.21.244.0/22" + "103.22.200.0/22" + "103.31.4.0/22" + "141.101.64.0/18" + "108.162.192.0/18" + "190.93.240.0/20" + "188.114.96.0/20" + "197.234.240.0/22" + "198.41.128.0/17" + "162.158.0.0/15" + "104.16.0.0/13" + "104.24.0.0/14" + "172.64.0.0/13" + "131.0.72.0/22" + + # Cloudflare IPv6: https://www.cloudflare.com/ips-v6 + "2400:cb00::/32" + "2606:4700::/32" + "2803:f800::/32" + "2405:b500::/32" + "2405:8100::/32" + "2a06:98c0::/29" + "2c0f:f248::/32" + + ]; }; }; From a9ae0c8858495b836c6871ed380b79559dfefacc Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:59:28 +0000 Subject: [PATCH 029/391] add activationscript for jellyfin directory --- modules/services/jellyfin.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index c866cc0..33828d9 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -18,6 +18,18 @@ upstreams = [{ dial = "localhost:8096"; }]; }]; }]; + + # Create videos directory, allow anyone in Jellyfin group to manage it + system.activationScripts.jellyfin = let videosDirectory = "/var/videos"; + in { + text = '' + if [ ! -d "${videosDirectory}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${videosDirectory} + $DRY_RUN_CMD chmod 775 $VERBOSE_ARG ${videosDirectory} + fi + ''; + }; + }; } From 0637cc693b778d4c439b6d267939b04b3d6673d8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 5 Oct 2022 03:59:13 +0000 Subject: [PATCH 030/391] fix: patch calibre-web cloudflare login issues --- modules/services/calibre-web-cloudflare.patch | 25 +++++++++++++++++++ modules/services/calibre.nix | 10 ++++++++ 2 files changed, 35 insertions(+) create mode 100644 modules/services/calibre-web-cloudflare.patch diff --git a/modules/services/calibre-web-cloudflare.patch b/modules/services/calibre-web-cloudflare.patch new file mode 100644 index 0000000..1e1363d --- /dev/null +++ b/modules/services/calibre-web-cloudflare.patch @@ -0,0 +1,25 @@ +diff --git a/cps/__init__.py b/cps/__init__.py +index 0b912d23..ad5d1fa9 100644 +--- a/cps/__init__.py ++++ b/cps/__init__.py +@@ -83,7 +83,6 @@ app.config.update( + lm = MyLoginManager() + lm.login_view = 'web.login' + lm.anonymous_user = ub.Anonymous +-lm.session_protection = 'strong' + + if wtf_present: + csrf = CSRFProtect() +diff --git a/cps/admin.py b/cps/admin.py +index 1004ee78..e295066e 100644 +--- a/cps/admin.py ++++ b/cps/admin.py +@@ -98,8 +98,6 @@ def before_request(): + # make remember me function work + if current_user.is_authenticated: + confirm_login() +- if not ub.check_user_session(current_user.id, flask_session.get('_id')) and 'opds' not in request.path: +- logout_user() + g.constants = constants + g.user = current_user + g.allow_registration = config.config_public_reg diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index b21c3de..8a72a24 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -25,9 +25,19 @@ in { calibreLibrary = libraryPath; reverseProxyAuth.enable = false; enableBookConversion = true; + enableBookUploading = true; }; }; + # Fix: https://github.com/janeczku/calibre-web/issues/2422 + nixpkgs.overlays = [ + (final: prev: { + calibre-web = prev.calibre-web.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ./calibre-web-cloudflare.patch ]; + }); + }) + ]; + caddyRoutes = [{ match = [{ host = [ config.bookServer ]; }]; handle = [{ From 4044721606b66b954700f003f19c1fdbe2a24787 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 7 Oct 2022 00:44:06 +0000 Subject: [PATCH 031/391] add vaultwarden, not activated --- modules/services/vaultwarden.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 modules/services/vaultwarden.nix diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix new file mode 100644 index 0000000..e452281 --- /dev/null +++ b/modules/services/vaultwarden.nix @@ -0,0 +1,24 @@ +{ config, pkgs, lib, ... }: { + + options = { + + vaultwardenServer = lib.mkOption { + description = "Hostname for Vaultwarden."; + type = lib.types.str; + }; + + }; + + config = { + services.vaultwarden = { + enable = true; + config = { + DOMAIN = config.vaultwardenServer; + SIGNUPS_ALLOWED = false; + }; + environmentFile = null; + dbBackend = "sqlite"; + }; + }; + +} From e89db82e7fc355380576e1195da8a3426fbeb64e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 7 Oct 2022 03:31:14 +0000 Subject: [PATCH 032/391] make whois core utility --- modules/darwin/utilities.nix | 3 ++- modules/shell/utilities.nix | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index ad50645..d73a6c3 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -16,7 +16,8 @@ vault consul noti # Create notifications programmatically - ipcalc + ipcalc # Make IP network calculations + whois # Lookup IPs (pkgs.writeScriptBin "ocr" (builtins.readFile ../shell/bash/scripts/ocr.sh)) ]; diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index 5e4a8b3..68c4583 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -31,6 +31,7 @@ in { vimv-rs # Batch rename files dig # DNS lookup lf # File viewer + whois # Lookup IPs ]; programs.zoxide.enable = true; # Shortcut jump command From 8dba2ef88b8126873c43e5ea0aec5405d9358e7e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 8 Oct 2022 15:52:05 +0000 Subject: [PATCH 033/391] litestream backups for nextcloud --- hosts/oracle/default.nix | 7 +++ modules/services/nextcloud.nix | 97 +++++++++++++++++++++++++++++----- private/backup.age | 6 +++ 3 files changed, 98 insertions(+), 12 deletions(-) create mode 100644 private/backup.age diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 8da7180..096185a 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -26,6 +26,13 @@ nixpkgs.lib.nixosSystem { publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + # Backup config + backupS3 = { + endpoint = "s3.us-west-002.backblazeb2.com"; + bucket = "noahmasur-backup"; + accessKeyId = "0026b0e73b2e2c80000000004"; + }; + # Grant access to Jellyfin directories from nextcloud users.users.nextcloud.extraGroups = [ "jellyfin" ]; } diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 296b352..c9ffa1e 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -1,6 +1,8 @@ { config, pkgs, lib, ... }: -let adminpassFile = "/var/lib/nextcloud/creds"; +let + adminpassFile = "/var/lib/nextcloud/creds"; + backupS3File = "/var/lib/nextcloud/backup-creds"; in { @@ -13,6 +15,22 @@ in { description = "Hostname for Nextcloud"; }; + # Options for backup + backupS3 = { + endpoint = lib.mkOption { + type = lib.types.str; + description = "S3 endpoint for backups"; + }; + bucket = lib.mkOption { + type = lib.types.str; + description = "S3 bucket for backups"; + }; + accessKeyId = lib.mkOption { + type = lib.types.str; + description = "S3 access key ID for backups"; + }; + }; + }; config = { @@ -72,18 +90,73 @@ in { }]; }]; - # Create credentials files - system.activationScripts.nextcloud = { - deps = [ "age" ]; - text = '' - if [ ! -f "${adminpassFile}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname ${adminpassFile}) - $DRY_RUN_CMD ${pkgs.age}/bin/age --decrypt \ + # Create credentials file for nextcloud + systemd.services.nextcloud-creds = { + requiredBy = [ "nextcloud-setup.service" ]; + before = [ "nextcloud-setup.service" ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + script = '' + mkdir --parents $(dirname ${adminpassFile}) + ${pkgs.age}/bin/age --decrypt \ + --identity ${config.identityFile} \ + --output ${adminpassFile} \ + ${builtins.toString ../../private/nextcloud.age} + chown nextcloud:nextcloud ${adminpassFile} + chmod 0700 ${adminpassFile} + ''; + }; + + ## Backup config + + # Open to groups, allowing for backups + systemd.services.phpfpm-nextcloud.serviceConfig.StateDirectoryMode = + lib.mkForce "0770"; + + # Allow litestream and nextcloud to share a sqlite database + users.users.litestream.extraGroups = [ "nextcloud" ]; + users.users.nextcloud.extraGroups = [ "litestream" ]; + + # Backup sqlite database with litestream + services.litestream = { + enable = true; + settings = { + dbs = [{ + path = "/var/lib/nextcloud/data/nextcloud.db"; + replicas = [{ + url = + "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/nextcloud"; + }]; + }]; + }; + environmentFile = backupS3File; + }; + + # Don't start litestream unless nextcloud is up + systemd.services.litestream = { + after = [ "phpfpm-nextcloud.service" ]; + requires = [ "phpfpm-nextcloud.service" ]; + environment.LITESTREAM_ACCESS_KEY_ID = config.backupS3.accessKeyId; + }; + + # Create credentials file for litestream + systemd.services.litestream-s3 = { + requiredBy = [ "litestream.service" ]; + before = [ "litestream.service" ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + script = '' + echo \ + LITESTREAM_SECRET_ACCESS_KEY=$(${pkgs.age}/bin/age --decrypt \ --identity ${config.identityFile} \ - --output ${adminpassFile} \ - ${builtins.toString ../../private/nextcloud.age} - $DRY_RUN_CMD chown nextcloud:nextcloud ${adminpassFile} - fi + ${builtins.toString ../../private/backup.age} \ + ) > ${backupS3File} + chown litestream:litestream ${backupS3File} + chmod 0700 ${backupS3File} ''; }; diff --git a/private/backup.age b/private/backup.age new file mode 100644 index 0000000..bc1483a --- /dev/null +++ b/private/backup.age @@ -0,0 +1,6 @@ +age-encryption.org/v1 +-> ssh-ed25519 MgHaOw 2y5C1sRq3NZqmfGBiPgMS7qcU5v+70wri5xkXbceaHM +zyd7b+OuVi3rxxUEm+QW/80M80SSKaebOwOioRjnYak +--- yZQxxjYYNouD5wnEj+qNjUSrRU01hXvWUuax4C252i8 +/2*MD^ӜOQ +5 Date: Sat, 8 Oct 2022 15:52:43 +0000 Subject: [PATCH 034/391] remember to require age for mail --- modules/mail/himalaya.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 8e528db..7e7363b 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -1,5 +1,8 @@ { config, pkgs, lib, ... }: { + # Required to place identity file on machine + imports = [ ../shell/age.nix ]; + options = { mailUser = lib.mkOption { type = lib.types.str; From 5872abcc330384a562f33262074e4ce294e9d501 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 8 Oct 2022 15:57:52 +0000 Subject: [PATCH 035/391] move calibre perms out of activations --- modules/services/calibre.nix | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 8a72a24..21c9707 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -48,18 +48,20 @@ in { }]; # Create directory and set permissions - system.activationScripts.calibreLibrary.text = '' - if [ ! -d "${libraryPath}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath} - fi - if [ ! "$(stat -c "%G" ${libraryPath})" = "calibre-web" ]; then - $DRY_RUN_CMD chown $VERBOSE_ARG -R calibre-web:calibre-web ${libraryPath} - fi - if [ ! "$(stat -c "%a" ${libraryPath})" = "775" ]; then - $DRY_RUN_CMD chmod $VERBOSE_ARG 0775 ${libraryPath} - $DRY_RUN_CMD chmod $VERBOSE_ARG -R 0640 ${libraryPath}/* - fi - ''; + systemd.services.calibre-library = { + requiredBy = [ "calibre-web.service" ]; + before = [ "calibre-web.service" ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + script = '' + mkdir --parents ${libraryPath} + chown -R calibre-web:calibre-web ${libraryPath} + chmod 0775 ${libraryPath} + chmod -R 0640 ${libraryPath}/* + ''; + }; }; From e309889b0bbe3a7358343151a4d05b71614c2a4b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 9 Oct 2022 03:51:25 +0000 Subject: [PATCH 036/391] replace activationscripts with systemd --- modules/services/jellyfin.nix | 19 ++++++++++++------- modules/services/nextcloud.nix | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index 33828d9..0f69c85 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -20,13 +20,18 @@ }]; # Create videos directory, allow anyone in Jellyfin group to manage it - system.activationScripts.jellyfin = let videosDirectory = "/var/videos"; - in { - text = '' - if [ ! -d "${videosDirectory}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${videosDirectory} - $DRY_RUN_CMD chmod 775 $VERBOSE_ARG ${videosDirectory} - fi + systemd.services.videos-library = { + wantedBy = [ "jellyfin.service" ]; + requiredBy = [ "jellyfin.service" ]; + before = [ "jellyfin.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = let videosDirectory = "/var/videos"; + in '' + mkdir --parents --mode 0755 ${videosDirectory} + chown jellyfin:jellyfin ${videosDirectory} ''; }; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index c9ffa1e..7c8e270 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -1,6 +1,7 @@ { config, pkgs, lib, ... }: let + adminpassFile = "/var/lib/nextcloud/creds"; backupS3File = "/var/lib/nextcloud/backup-creds"; @@ -147,7 +148,7 @@ in { before = [ "litestream.service" ]; serviceConfig = { Type = "oneshot"; - User = "root"; + RemainAfterExit = true; }; script = '' echo \ From 129e4bba4bb88d5520ce682014c6b0b37fe6c177 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:12:31 +0000 Subject: [PATCH 037/391] wireguard working but not transmission --- hosts/oracle/default.nix | 2 + modules/services/transmission.nix | 92 +++++++++++++++++++++++++++++++ modules/services/wireguard.nix | 71 ++++++++++++++++++++++-- private/transmission.json.age | 5 ++ private/wireguard.age | 5 ++ 5 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 modules/services/transmission.nix create mode 100644 private/transmission.json.age create mode 100644 private/wireguard.age diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 096185a..fb22aa8 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -20,6 +20,7 @@ nixpkgs.lib.nixosSystem { bookServer = "books.masu.rs"; streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; + transmissionServer = "download.masu.rs"; # Disable passwords, only use SSH key passwordHash = null; @@ -44,5 +45,6 @@ nixpkgs.lib.nixosSystem { ../../modules/services/calibre.nix ../../modules/services/jellyfin.nix ../../modules/services/nextcloud.nix + ../../modules/services/transmission.nix ]; } diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix new file mode 100644 index 0000000..d224ba6 --- /dev/null +++ b/modules/services/transmission.nix @@ -0,0 +1,92 @@ +{ config, pkgs, lib, ... }: + +let credentialsFile = "/var/lib/private/transmission.json"; + +in { + + imports = [ ./wireguard.nix ]; + + options = { + transmissionServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for Transmission"; + }; + }; + + config = { + + # Setup transmission + services.transmission = { + enable = true; + settings = { + port-forwarding-enabled = false; + rpc-authentication-required = true; + rpc-port = 9091; + rpc-bind-address = "0.0.0.0"; + rpc-username = config.user; + rpc-host-whitelist = config.transmissionServer; + rpc-host-whitelist-enabled = true; + rpc-whitelist-enabled = false; + }; + credentialsFile = credentialsFile; + }; + + # Bind transmission to wireguard namespace + systemd.services.transmission = { + bindsTo = [ "netns@wg.service" ]; + requires = [ "network-online.target" ]; + after = [ "wireguard-wg0.service" ]; + unitConfig.JoinsNamespaceOf = "netns@wg.service"; + serviceConfig = { PrivateNetwork = true; }; + }; + + # Create reverse proxy for web UI + caddyRoutes = [{ + match = [{ host = [ config.transmissionServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:9091"; }]; + }]; + }]; + + # Allow inbound connections to reach namespace + systemd.services.transmission-web-netns = { + description = "Forward to transmission in netns"; + requires = [ "transmission.service" ]; + after = [ "transmission.service" ]; + serviceConfig = { + User = "transmission"; + Group = "transmission"; + Restart = "on-failure"; + TimeoutStopSec = 300; + }; + wantedBy = [ "multi-user.target" ]; + script = '' + ${pkgs.socat}/bin/socat tcp-listen:9091,fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec wg ${pkgs.socat}/bin/socat STDIO "tcp-connect:10.66.13.200:9091"',nofork + ''; + }; + + # Create credentials file for transmission + systemd.services.transmission-creds = { + requiredBy = [ "transmission.service" ]; + before = [ "transmission.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + if [ ! -f "${credentialsFile}" ]; then + mkdir --parents ${builtins.dirOf credentialsFile} + ${pkgs.age}/bin/age --decrypt \ + --identity ${config.identityFile} \ + --output ${credentialsFile} \ + ${builtins.toString ../../private/transmission.json.age} + chown transmission:transmission ${credentialsFile} + chmod 0700 ${credentialsFile} + fi + ''; + }; + + }; + +} diff --git a/modules/services/wireguard.nix b/modules/services/wireguard.nix index 34af565..e6eba2e 100644 --- a/modules/services/wireguard.nix +++ b/modules/services/wireguard.nix @@ -1,18 +1,77 @@ -{ ... }: { +{ config, pkgs, ... }: + +let privateKeyFile = "/private/wireguard/wg0"; + +in { + networking.wireguard = { enable = true; interfaces = { wg0 = { - ips = [ "10.66.127.235/32" "fc00:bbbb:bbbb:bb01::3:7fea/128" ]; - generatePrivateKeyFile = true; - privateKeyFile = "/private/wireguard/wg0"; + + # The local IPs for this machine within the Wireguard network + # Any inbound traffic bound for these IPs should be kept on localhost + ips = [ "10.66.13.200/32" "fc00:bbbb:bbbb:bb01::3:dc7/128" ]; + + # Establishes identity of this machine + generatePrivateKeyFile = false; + privateKeyFile = privateKeyFile; + peers = [{ - publicKey = "cVDIYPzNChIeANp+0jE12kWM5Ga1MbmNErT1Pmaf12A="; + + # Identity of Wireguard target peer (VPN) + publicKey = "bOOP5lIjqCdDx5t+mP/kEcSbHS4cZqE0rMlBI178lyY="; + + # Which outgoing IP ranges should be sent through Wireguard allowedIPs = [ "0.0.0.0/0" "::0/0" ]; - endpoint = "89.46.62.197:51820"; + + # The public internet address of the target peer + endpoint = "86.106.143.132:51820"; + + # Send heartbeat signal within the network persistentKeepalive = 25; + }]; + + # Namespaces + interfaceNamespace = "wg"; + # socketNamespace = "wg"; + }; }; }; + + # Create namespace for Wireguard + systemd.services."netns@" = { + description = "%I network namespace"; + before = [ "network.target" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${pkgs.iproute2}/bin/ip netns add %I"; + ExecStop = "${pkgs.iproute2}/bin/ip netns del %I"; + }; + }; + + # Private key file for wireguard + systemd.services.wireguard-private-key = { + wantedBy = [ "wireguard-wg0.service" ]; + requiredBy = [ "wireguard-wg0.service" ]; + before = [ "wireguard-wg0.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + mkdir --parents --mode 0755 ${builtins.dirOf privateKeyFile} + if [ ! -f "${privateKeyFile}" ]; then + ${pkgs.age}/bin/age --decrypt \ + --identity ${config.identityFile} \ + --output ${privateKeyFile} \ + ${builtins.toString ../../private/wireguard.age} + chmod 0700 ${privateKeyFile} + fi + ''; + }; + } diff --git a/private/transmission.json.age b/private/transmission.json.age new file mode 100644 index 0000000..a98cddd --- /dev/null +++ b/private/transmission.json.age @@ -0,0 +1,5 @@ +age-encryption.org/v1 +-> ssh-ed25519 MgHaOw PAAWnpc5bJ5S972U+L6YgHpI2a7aqwxWaNZrvQIODVg +A6zRWD6TmlVb8b5J3gdMf3JAeHIHgUQA3C8PpR8GveQ +--- xP8vbUGtTlvaZ0K2J0+J0ICoL9gvCbhQg6GxG8ZYCS0 +75L2cJĀe,ݝTn$Mi4Yi[! ŁL%(iF;6ԊjO \ No newline at end of file diff --git a/private/wireguard.age b/private/wireguard.age new file mode 100644 index 0000000..a055a02 --- /dev/null +++ b/private/wireguard.age @@ -0,0 +1,5 @@ +age-encryption.org/v1 +-> ssh-ed25519 MgHaOw lG6VtLpEU/33egpB9WqJiulVdL3K5a2IGjekIu6HtSI +VsAfCbtQuHU9tptKQR4buD3ydwb89aSbUVdEoetU1gc +--- kts74pY8NdQh4pTlMT3NTHxU0qnA0txwQKH5FkQCdXA +S8A 0`0$,1*/HV ZtWBC[ Date: Sun, 9 Oct 2022 18:32:43 +0000 Subject: [PATCH 038/391] transmission reaches internet through vpn --- modules/services/transmission.nix | 6 ++---- modules/services/wireguard.nix | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index d224ba6..cb9e827 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -37,7 +37,7 @@ in { requires = [ "network-online.target" ]; after = [ "wireguard-wg0.service" ]; unitConfig.JoinsNamespaceOf = "netns@wg.service"; - serviceConfig = { PrivateNetwork = true; }; + serviceConfig.NetworkNamespacePath = "/var/run/netns/wg"; }; # Create reverse proxy for web UI @@ -51,12 +51,10 @@ in { # Allow inbound connections to reach namespace systemd.services.transmission-web-netns = { - description = "Forward to transmission in netns"; + description = "Forward to transmission in wireguard namespace"; requires = [ "transmission.service" ]; after = [ "transmission.service" ]; serviceConfig = { - User = "transmission"; - Group = "transmission"; Restart = "on-failure"; TimeoutStopSec = 300; }; diff --git a/modules/services/wireguard.nix b/modules/services/wireguard.nix index e6eba2e..40fb6e7 100644 --- a/modules/services/wireguard.nix +++ b/modules/services/wireguard.nix @@ -33,15 +33,15 @@ in { }]; - # Namespaces + # Move to network namespace for isolating programs interfaceNamespace = "wg"; - # socketNamespace = "wg"; }; }; }; # Create namespace for Wireguard + # This allows us to isolate specific programs to Wireguard systemd.services."netns@" = { description = "%I network namespace"; before = [ "network.target" ]; @@ -53,7 +53,7 @@ in { }; }; - # Private key file for wireguard + # Create private key file for wireguard systemd.services.wireguard-private-key = { wantedBy = [ "wireguard-wg0.service" ]; requiredBy = [ "wireguard-wg0.service" ]; From 7aacfe7887fc49b9e4acd2cc497bd25a50f3a865 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 9 Oct 2022 20:41:04 +0000 Subject: [PATCH 039/391] fix issues reaching transmission web --- modules/services/transmission.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index cb9e827..2defc89 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -60,6 +60,7 @@ in { }; wantedBy = [ "multi-user.target" ]; script = '' + ${pkgs.iproute2}/bin/ip netns exec wg ${pkgs.iproute2}/bin/ip link set dev lo up ${pkgs.socat}/bin/socat tcp-listen:9091,fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec wg ${pkgs.socat}/bin/socat STDIO "tcp-connect:10.66.13.200:9091"',nofork ''; }; From b0aa82e7d0713394de49275cdbd84b169b2c0e52 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 10 Oct 2022 03:13:16 +0000 Subject: [PATCH 040/391] refactor wireguard and add port forwarding --- hosts/oracle/default.nix | 35 ++++++++- modules/services/transmission.nix | 14 ++-- modules/services/wireguard.nix | 114 ++++++++++++++---------------- 3 files changed, 95 insertions(+), 68 deletions(-) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index fb22aa8..5b1f3ba 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -27,15 +27,46 @@ nixpkgs.lib.nixosSystem { publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; - # Backup config + # Nextcloud backup config backupS3 = { endpoint = "s3.us-west-002.backblazeb2.com"; bucket = "noahmasur-backup"; accessKeyId = "0026b0e73b2e2c80000000004"; }; - # Grant access to Jellyfin directories from nextcloud + # Grant access to Jellyfin directories from Nextcloud users.users.nextcloud.extraGroups = [ "jellyfin" ]; + + # Wireguard config for Transmission + networking.wireguard.interfaces.wg0 = { + + # The local IPs for this machine within the Wireguard network + # Any inbound traffic bound for these IPs should be kept on localhost + ips = [ "10.66.13.200/32" "fc00:bbbb:bbbb:bb01::3:dc7/128" ]; + + peers = [{ + + # Identity of Wireguard target peer (VPN) + publicKey = "bOOP5lIjqCdDx5t+mP/kEcSbHS4cZqE0rMlBI178lyY="; + + # The public internet address of the target peer + endpoint = "86.106.143.132:51820"; + + # Which outgoing IP ranges should be sent through Wireguard + allowedIPs = [ "0.0.0.0/0" "::0/0" ]; + + # Send heartbeat signal within the network + persistentKeepalive = 25; + + }]; + + }; + + # VPN port forwarding + services.transmission.settings.peer-port = 57599; + + # Grant access to Transmission directories from Jellyfin + users.users.jellyfin.extraGroups = [ "transmission" ]; } ./hardware-configuration.nix ../common.nix diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 2defc89..00bcfec 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -13,7 +13,9 @@ in { }; }; - config = { + config = let + namespace = config.networking.wireguard.interfaces.wg0.interfaceNamespace; + in { # Setup transmission services.transmission = { @@ -33,11 +35,11 @@ in { # Bind transmission to wireguard namespace systemd.services.transmission = { - bindsTo = [ "netns@wg.service" ]; + bindsTo = [ "netns@${namespace}.service" ]; requires = [ "network-online.target" ]; after = [ "wireguard-wg0.service" ]; - unitConfig.JoinsNamespaceOf = "netns@wg.service"; - serviceConfig.NetworkNamespacePath = "/var/run/netns/wg"; + unitConfig.JoinsNamespaceOf = "netns@${namespace}.service"; + serviceConfig.NetworkNamespacePath = "/var/run/netns/${namespace}"; }; # Create reverse proxy for web UI @@ -60,8 +62,8 @@ in { }; wantedBy = [ "multi-user.target" ]; script = '' - ${pkgs.iproute2}/bin/ip netns exec wg ${pkgs.iproute2}/bin/ip link set dev lo up - ${pkgs.socat}/bin/socat tcp-listen:9091,fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec wg ${pkgs.socat}/bin/socat STDIO "tcp-connect:10.66.13.200:9091"',nofork + ${pkgs.iproute2}/bin/ip netns exec ${namespace} ${pkgs.iproute2}/bin/ip link set dev lo up + ${pkgs.socat}/bin/socat tcp-listen:9091,fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec ${namespace} ${pkgs.socat}/bin/socat STDIO "tcp-connect:10.66.13.200:9091"',nofork ''; }; diff --git a/modules/services/wireguard.nix b/modules/services/wireguard.nix index 40fb6e7..96bb196 100644 --- a/modules/services/wireguard.nix +++ b/modules/services/wireguard.nix @@ -1,77 +1,71 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { -let privateKeyFile = "/private/wireguard/wg0"; + options.networking.wireguard = { -in { + encryptedPrivateKey = lib.mkOption { + type = lib.types.path; + description = "Nix path to age-encrypted client private key"; + default = ../../private/wireguard.age; + }; - networking.wireguard = { - enable = true; - interfaces = { - wg0 = { + }; - # The local IPs for this machine within the Wireguard network - # Any inbound traffic bound for these IPs should be kept on localhost - ips = [ "10.66.13.200/32" "fc00:bbbb:bbbb:bb01::3:dc7/128" ]; + config = { - # Establishes identity of this machine - generatePrivateKeyFile = false; - privateKeyFile = privateKeyFile; + networking.wireguard = { + enable = true; + interfaces = { + wg0 = { - peers = [{ + # Establishes identity of this machine + generatePrivateKeyFile = false; + privateKeyFile = "/private/wireguard/wg0"; - # Identity of Wireguard target peer (VPN) - publicKey = "bOOP5lIjqCdDx5t+mP/kEcSbHS4cZqE0rMlBI178lyY="; - - # Which outgoing IP ranges should be sent through Wireguard - allowedIPs = [ "0.0.0.0/0" "::0/0" ]; - - # The public internet address of the target peer - endpoint = "86.106.143.132:51820"; - - # Send heartbeat signal within the network - persistentKeepalive = 25; - - }]; - - # Move to network namespace for isolating programs - interfaceNamespace = "wg"; + # Move to network namespace for isolating programs + interfaceNamespace = "wg"; + }; }; }; - }; - # Create namespace for Wireguard - # This allows us to isolate specific programs to Wireguard - systemd.services."netns@" = { - description = "%I network namespace"; - before = [ "network.target" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - ExecStart = "${pkgs.iproute2}/bin/ip netns add %I"; - ExecStop = "${pkgs.iproute2}/bin/ip netns del %I"; + # Create namespace for Wireguard + # This allows us to isolate specific programs to Wireguard + systemd.services."netns@" = { + description = "%I network namespace"; + before = [ "network.target" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${pkgs.iproute2}/bin/ip netns add %I"; + ExecStop = "${pkgs.iproute2}/bin/ip netns del %I"; + }; }; - }; - # Create private key file for wireguard - systemd.services.wireguard-private-key = { - wantedBy = [ "wireguard-wg0.service" ]; - requiredBy = [ "wireguard-wg0.service" ]; - before = [ "wireguard-wg0.service" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; + # Create private key file for wireguard + systemd.services.wireguard-private-key = { + wantedBy = [ "wireguard-wg0.service" ]; + requiredBy = [ "wireguard-wg0.service" ]; + before = [ "wireguard-wg0.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = let + encryptedPrivateKey = config.networking.wireguard.encryptedPrivateKey; + privateKeyFile = + config.networking.wireguard.interfaces.wg0.privateKeyFile; + in '' + mkdir --parents --mode 0755 ${builtins.dirOf privateKeyFile} + if [ ! -f "${privateKeyFile}" ]; then + ${pkgs.age}/bin/age --decrypt \ + --identity ${config.identityFile} \ + --output ${privateKeyFile} \ + ${builtins.toString encryptedPrivateKey} + chmod 0700 ${privateKeyFile} + fi + ''; }; - script = '' - mkdir --parents --mode 0755 ${builtins.dirOf privateKeyFile} - if [ ! -f "${privateKeyFile}" ]; then - ${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - --output ${privateKeyFile} \ - ${builtins.toString ../../private/wireguard.age} - chmod 0700 ${privateKeyFile} - fi - ''; + }; } From 170f8c67de0646a7e3c1b24728a3b2490d942d21 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 10 Oct 2022 03:25:28 +0000 Subject: [PATCH 041/391] enable transmission web allowlist --- modules/services/transmission.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 00bcfec..89f2a00 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -15,6 +15,8 @@ in { config = let namespace = config.networking.wireguard.interfaces.wg0.interfaceNamespace; + vpnIp = lib.strings.removeSuffix "/32" + (builtins.head config.networking.wireguard.interfaces.wg0.ips); in { # Setup transmission @@ -28,7 +30,8 @@ in { rpc-username = config.user; rpc-host-whitelist = config.transmissionServer; rpc-host-whitelist-enabled = true; - rpc-whitelist-enabled = false; + rpc-whitelist = "127.0.0.1,${vpnIp}"; + rpc-whitelist-enabled = true; }; credentialsFile = credentialsFile; }; @@ -63,7 +66,7 @@ in { wantedBy = [ "multi-user.target" ]; script = '' ${pkgs.iproute2}/bin/ip netns exec ${namespace} ${pkgs.iproute2}/bin/ip link set dev lo up - ${pkgs.socat}/bin/socat tcp-listen:9091,fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec ${namespace} ${pkgs.socat}/bin/socat STDIO "tcp-connect:10.66.13.200:9091"',nofork + ${pkgs.socat}/bin/socat tcp-listen:9091,fork,reuseaddr exec:'${pkgs.iproute2}/bin/ip netns exec ${namespace} ${pkgs.socat}/bin/socat STDIO "tcp-connect:${vpnIp}:9091"',nofork ''; }; From a5e186ee87c3821c34b103c1ba9c3e1291935de8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:11:08 +0000 Subject: [PATCH 042/391] netdata metrics with basic auth seems to have performance problems with caddy --- hosts/oracle/default.nix | 6 +++++ modules/services/metrics.nix | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 modules/services/metrics.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 5b1f3ba..73653e8 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -21,12 +21,17 @@ nixpkgs.lib.nixosSystem { streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; transmissionServer = "download.masu.rs"; + metricsServer = "metrics.masu.rs"; # Disable passwords, only use SSH key passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + # Password for metrics server + metricsPasswordHashed = + "$2a$14$rr.lPIF8ktl5bepks1iD3OXu5Se11/uAog01wlFMwgk0MCb1Rm3PG"; + # Nextcloud backup config backupS3 = { endpoint = "s3.us-west-002.backblazeb2.com"; @@ -77,5 +82,6 @@ nixpkgs.lib.nixosSystem { ../../modules/services/jellyfin.nix ../../modules/services/nextcloud.nix ../../modules/services/transmission.nix + ../../modules/services/metrics.nix ]; } diff --git a/modules/services/metrics.nix b/modules/services/metrics.nix new file mode 100644 index 0000000..8239fdd --- /dev/null +++ b/modules/services/metrics.nix @@ -0,0 +1,43 @@ +{ config, lib, ... }: { + + options = { + metricsServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for Metrics server"; + }; + metricsPasswordHashed = lib.mkOption { + type = lib.types.str; + description = "Metrics password hashed with `caddy hash-password`"; + }; + }; + + imports = [ ./caddy.nix ]; + + config = { + + services.netdata.enable = true; + + caddyRoutes = [{ + match = [{ host = [ config.metricsServer ]; }]; + handle = [ + { + handler = "authentication"; + providers = { + http_basic = { + accounts = [{ + username = config.user; + password = config.metricsPasswordHashed; + }]; + }; + }; + } + { + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:19999"; }]; + } + ]; + }]; + + }; + +} From c4c75cd58701307f3ec0e068341b163462cec585 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 10 Oct 2022 19:22:39 +0000 Subject: [PATCH 043/391] switch to netdata cloud fix performance issues with caddy mostly --- apps/netdata-cloud.nix | 19 ++++++++++++++++ flake.nix | 3 +++ hosts/oracle/default.nix | 5 ----- modules/services/metrics.nix | 41 +++++----------------------------- modules/services/nextcloud.nix | 5 +---- 5 files changed, 29 insertions(+), 44 deletions(-) create mode 100644 apps/netdata-cloud.nix diff --git a/apps/netdata-cloud.nix b/apps/netdata-cloud.nix new file mode 100644 index 0000000..f98dbd7 --- /dev/null +++ b/apps/netdata-cloud.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "netdata-cloud" '' + if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit 1 + fi + mkdir --parents --mode 0750 /var/lib/netdata/cloud.d + printf "\nEnter the claim token for netdata cloud...\n\n" + read -p "Token: " token + echo "''${token}" > /var/lib/netdata/cloud.d/token + chown -R netdata:netdata /var/lib/netdata + ${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen) + printf "\n\nNow restart netdata service.\n\n" + ''); + +} diff --git a/flake.nix b/flake.nix index d1aff1c..04c5811 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,9 @@ # Load the SSH key for this machine loadkey = import ./apps/loadkey.nix { inherit pkgs; }; + # Connect machine metrics to Netdata Cloud + netdata = import ./apps/netdata-cloud.nix { inherit pkgs; }; + }); devShells = forAllSystems (system: diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 73653e8..f34d32a 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -21,17 +21,12 @@ nixpkgs.lib.nixosSystem { streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; transmissionServer = "download.masu.rs"; - metricsServer = "metrics.masu.rs"; # Disable passwords, only use SSH key passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; - # Password for metrics server - metricsPasswordHashed = - "$2a$14$rr.lPIF8ktl5bepks1iD3OXu5Se11/uAog01wlFMwgk0MCb1Rm3PG"; - # Nextcloud backup config backupS3 = { endpoint = "s3.us-west-002.backblazeb2.com"; diff --git a/modules/services/metrics.nix b/modules/services/metrics.nix index 8239fdd..cc14d8d 100644 --- a/modules/services/metrics.nix +++ b/modules/services/metrics.nix @@ -1,42 +1,13 @@ -{ config, lib, ... }: { - - options = { - metricsServer = lib.mkOption { - type = lib.types.str; - description = "Hostname for Metrics server"; - }; - metricsPasswordHashed = lib.mkOption { - type = lib.types.str; - description = "Metrics password hashed with `caddy hash-password`"; - }; - }; - - imports = [ ./caddy.nix ]; +{ config, pkgs, lib, ... }: { config = { - services.netdata.enable = true; + services.netdata = { + enable = true; - caddyRoutes = [{ - match = [{ host = [ config.metricsServer ]; }]; - handle = [ - { - handler = "authentication"; - providers = { - http_basic = { - accounts = [{ - username = config.user; - password = config.metricsPasswordHashed; - }]; - }; - }; - } - { - handler = "reverse_proxy"; - upstreams = [{ dial = "localhost:19999"; }]; - } - ]; - }]; + # Disable local dashboard (unsecured) + config = { web.mode = "none"; }; + }; }; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 7c8e270..40a3a2c 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -146,10 +146,7 @@ in { systemd.services.litestream-s3 = { requiredBy = [ "litestream.service" ]; before = [ "litestream.service" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; + serviceConfig = { Type = "oneshot"; }; script = '' echo \ LITESTREAM_SECRET_ACCESS_KEY=$(${pkgs.age}/bin/age --decrypt \ From 01e71e5810d12c5bee6ab0d754c09c421670cf39 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 10 Oct 2022 23:09:32 +0000 Subject: [PATCH 044/391] add minecraft server --- hosts/oracle/default.nix | 1 + modules/gaming/minecraft-server.nix | 32 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 modules/gaming/minecraft-server.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index f34d32a..9758d53 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -78,5 +78,6 @@ nixpkgs.lib.nixosSystem { ../../modules/services/nextcloud.nix ../../modules/services/transmission.nix ../../modules/services/metrics.nix + ../../modules/gaming/minecraft-server.nix ]; } diff --git a/modules/gaming/minecraft-server.nix b/modules/gaming/minecraft-server.nix new file mode 100644 index 0000000..3da55a3 --- /dev/null +++ b/modules/gaming/minecraft-server.nix @@ -0,0 +1,32 @@ +{ ... }: { + + unfreePackages = [ "minecraft-server" ]; + + services.minecraft-server = { + enable = true; + eula = true; + declarative = true; + whitelist = { }; + openFirewall = true; + serverProperties = { + server-port = 25565; + difficulty = "normal"; + gamemode = "survival"; + white-list = false; + enforce-whitelist = false; + level-name = "world"; + motd = "Welcome!"; + pvp = true; + player-idle-timeout = 30; + generate-structures = true; + max-players = 20; + snooper-enabled = false; + spawn-npcs = true; + spawn-animals = true; + spawn-monsters = true; + allow-nether = true; + allow-flight = false; + }; + }; + +} From e2af159c26347afd0926a4343fdc8f2101ff42ff Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Oct 2022 23:40:30 +0000 Subject: [PATCH 045/391] lockdown caddy and ssh connections --- modules/services/caddy.nix | 45 +++++++++++++++++++++++++++++++++----- modules/services/sshd.nix | 3 +++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix index d737f34..02c8f00 100644 --- a/modules/services/caddy.nix +++ b/modules/services/caddy.nix @@ -1,8 +1,4 @@ -{ config, pkgs, lib, ... }: - -let - -in { +{ config, pkgs, lib, ... }: { options = { caddyRoutes = lib.mkOption { @@ -20,6 +16,45 @@ in { apps.http.servers.main = { listen = [ ":443" ]; routes = config.caddyRoutes; + errors.routes = [{ + match = [{ + not = [{ + remote_ip.ranges = [ + + # Cloudflare IPv4: https://www.cloudflare.com/ips-v4 + "173.245.48.0/20" + "103.21.244.0/22" + "103.22.200.0/22" + "103.31.4.0/22" + "141.101.64.0/18" + "108.162.192.0/18" + "190.93.240.0/20" + "188.114.96.0/20" + "197.234.240.0/22" + "198.41.128.0/17" + "162.158.0.0/15" + "104.16.0.0/13" + "104.24.0.0/14" + "172.64.0.0/13" + "131.0.72.0/22" + + # Cloudflare IPv6: https://www.cloudflare.com/ips-v6 + "2400:cb00::/32" + "2606:4700::/32" + "2803:f800::/32" + "2405:b500::/32" + "2405:8100::/32" + "2a06:98c0::/29" + "2c0f:f248::/32" + + ]; + }]; + }]; + handle = [{ + handler = "static_response"; + abort = true; + }]; + }]; }; }); diff --git a/modules/services/sshd.nix b/modules/services/sshd.nix index 0161aba..094d624 100644 --- a/modules/services/sshd.nix +++ b/modules/services/sshd.nix @@ -25,6 +25,9 @@ users.users.${config.user}.openssh.authorizedKeys.keys = [ config.publicKey ]; + + # Implement a simple fail2ban service for sshd + services.sshguard.enable = true; }; } From c2d0037bab3107cefa919831594c9a4c61ca6317 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:34:35 +0000 Subject: [PATCH 046/391] autostart and stop minecraft server --- modules/gaming/minecraft-server.nix | 120 +++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 3 deletions(-) diff --git a/modules/gaming/minecraft-server.nix b/modules/gaming/minecraft-server.nix index 3da55a3..f27b6f0 100644 --- a/modules/gaming/minecraft-server.nix +++ b/modules/gaming/minecraft-server.nix @@ -1,4 +1,13 @@ -{ ... }: { +{ pkgs, ... }: + +let + + localPort = 25564; + publicPort = 25565; + rconPort = 25575; + rconPassword = "thiscanbeanything"; + +in { unfreePackages = [ "minecraft-server" ]; @@ -7,9 +16,9 @@ eula = true; declarative = true; whitelist = { }; - openFirewall = true; + openFirewall = false; serverProperties = { - server-port = 25565; + server-port = localPort; difficulty = "normal"; gamemode = "survival"; white-list = false; @@ -26,7 +35,112 @@ spawn-monsters = true; allow-nether = true; allow-flight = false; + enable-rcon = true; + "rcon.port" = rconPort; + "rcon.password" = rconPassword; }; }; + networking.firewall.allowedTCPPorts = [ publicPort ]; + + ## Automatically start and stop Minecraft server based on player connections + + # Adapted shamelessly from: + # https://dataswamp.org/~solene/2022-08-20-on-demand-minecraft-with-systemd.html + + # Prevent Minecraft from starting by default + systemd.services.minecraft-server = { wantedBy = pkgs.lib.mkForce [ ]; }; + + # Listen for connections on the public port, to trigger the actual + # listen-minecraft service. + systemd.sockets.listen-minecraft = { + wantedBy = [ "sockets.target" ]; + requires = [ "network.target" ]; + listenStreams = [ "${toString publicPort}" ]; + }; + + # Proxy traffic to local port, and trigger hook-minecraft + systemd.services.listen-minecraft = { + path = [ pkgs.systemd ]; + requires = [ "hook-minecraft.service" "listen-minecraft.socket" ]; + after = [ "hook-minecraft.service" "listen-minecraft.socket" ]; + serviceConfig.ExecStart = + "${pkgs.systemd.out}/lib/systemd/systemd-socket-proxyd 127.0.0.1:${ + toString localPort + }"; + }; + + # Start Minecraft if required and wait for it to be available + # Then unlock the listen-minecraft.service + systemd.services.hook-minecraft = { + path = with pkgs; [ systemd libressl busybox ]; + + # Start Minecraft and the auto-shutdown timer + script = '' + systemctl start minecraft-server.service + systemctl start stop-minecraft.timer + ''; + + # Keep checking until the service is available + postStart = '' + for i in $(seq 60); do + if ${pkgs.libressl.nc}/bin/nc -z 127.0.0.1 ${ + toString localPort + } > /dev/null ; then + exit 0 + fi + ${pkgs.busybox.out}/bin/sleep 1 + done + exit 1 + ''; + }; + + # Run a player check on a schedule for auto-shutdown + systemd.timers.stop-minecraft = { + timerConfig = { + OnCalendar = "*-*-* *:*:0/20"; # Every 20 seconds + Unit = "stop-minecraft.service"; + }; + wantedBy = [ "timers.target" ]; + }; + + # If no players are connected, then stop services and prepare to resume again + systemd.services.stop-minecraft = { + serviceConfig.Type = "oneshot"; + script = '' + # Check when service was launched + servicestartsec=$( + date -d \ + "$(systemctl show \ + --property=ActiveEnterTimestamp \ + minecraft-server.service \ + | cut -d= -f2)" \ + +%s) + + # Calculate elapsed time + serviceelapsedsec=$(( $(date +%s) - servicestartsec)) + + # Ignore if service just started + if [ $serviceelapsedsec -lt 180 ] + then + echo "Server was just started" + exit 0 + fi + + PLAYERS=$( + printf "list\n" \ + | ${pkgs.rcon.out}/bin/rcon -m \ + -H 127.0.0.1 -p ${builtins.toString rconPort} -P ${rconPassword} \ + ) + + if echo "$PLAYERS" | grep "are 0 of a" + then + echo "Stopping server" + systemctl stop minecraft-server.service + systemctl stop hook-minecraft.service + systemctl stop stop-minecraft.timer + fi + ''; + }; + } From a17a048d9db1d4de1437f87e0e5a21ff5c46c685 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:35:14 +0000 Subject: [PATCH 047/391] set credentials oneshots to stop after launch --- modules/services/transmission.nix | 5 +---- modules/services/wireguard.nix | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 89f2a00..0a6f9dd 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -74,10 +74,7 @@ in { systemd.services.transmission-creds = { requiredBy = [ "transmission.service" ]; before = [ "transmission.service" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; + serviceConfig = { Type = "oneshot"; }; script = '' if [ ! -f "${credentialsFile}" ]; then mkdir --parents ${builtins.dirOf credentialsFile} diff --git a/modules/services/wireguard.nix b/modules/services/wireguard.nix index 96bb196..4b437b9 100644 --- a/modules/services/wireguard.nix +++ b/modules/services/wireguard.nix @@ -46,10 +46,7 @@ wantedBy = [ "wireguard-wg0.service" ]; requiredBy = [ "wireguard-wg0.service" ]; before = [ "wireguard-wg0.service" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; + serviceConfig = { Type = "oneshot"; }; script = let encryptedPrivateKey = config.networking.wireguard.encryptedPrivateKey; privateKeyFile = From 595eac9367202ad8bdba2e9e3642e1e5ab3aee5d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 14 Oct 2022 04:01:41 +0000 Subject: [PATCH 048/391] switch from netdata to grafana --- hosts/oracle/default.nix | 2 +- modules/services/{metrics.nix => netdata.nix} | 0 modules/services/prometheus.nix | 31 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) rename modules/services/{metrics.nix => netdata.nix} (100%) create mode 100644 modules/services/prometheus.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 9758d53..1f1d730 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -77,7 +77,7 @@ nixpkgs.lib.nixosSystem { ../../modules/services/jellyfin.nix ../../modules/services/nextcloud.nix ../../modules/services/transmission.nix - ../../modules/services/metrics.nix + ../../modules/services/prometheus.nix ../../modules/gaming/minecraft-server.nix ]; } diff --git a/modules/services/metrics.nix b/modules/services/netdata.nix similarity index 100% rename from modules/services/metrics.nix rename to modules/services/netdata.nix diff --git a/modules/services/prometheus.nix b/modules/services/prometheus.nix new file mode 100644 index 0000000..01ae122 --- /dev/null +++ b/modules/services/prometheus.nix @@ -0,0 +1,31 @@ +{ config, pkgs, lib, ... }: { + + options.metricsServer = lib.mkOption { + type = lib.types.str; + description = "Hostname of the Grafana server."; + default = "grafana.masu.rs"; + }; + + config = { + + services.grafana.enable = true; + services.prometheus = { + enable = true; + exporters.node.enable = true; + scrapeConfigs = [{ + job_name = "local"; + static_configs = [{ targets = [ "127.0.0.1:9100" ]; }]; + }]; + }; + + caddyRoutes = [{ + match = [{ host = [ config.metricsServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:3000"; }]; + }]; + }]; + + }; + +} From 8cce61f4a850190e6a10a297f7d480540362b63c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 14 Oct 2022 13:08:13 +0000 Subject: [PATCH 049/391] change metrics server hostname --- hosts/oracle/default.nix | 1 + modules/services/prometheus.nix | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 1f1d730..cb6f239 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -21,6 +21,7 @@ nixpkgs.lib.nixosSystem { streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; transmissionServer = "download.masu.rs"; + metricsServer = "metrics.masu.rs"; # Disable passwords, only use SSH key passwordHash = null; diff --git a/modules/services/prometheus.nix b/modules/services/prometheus.nix index 01ae122..543540a 100644 --- a/modules/services/prometheus.nix +++ b/modules/services/prometheus.nix @@ -3,7 +3,6 @@ options.metricsServer = lib.mkOption { type = lib.types.str; description = "Hostname of the Grafana server."; - default = "grafana.masu.rs"; }; config = { From bc83c818db3f5dfa0161cf6bd736c40a8bdc8a56 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 15 Oct 2022 12:16:05 +0000 Subject: [PATCH 050/391] honeypot for banning port scanners --- modules/gaming/minecraft-server.nix | 2 +- modules/services/honeypot.nix | 75 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 modules/services/honeypot.nix diff --git a/modules/gaming/minecraft-server.nix b/modules/gaming/minecraft-server.nix index f27b6f0..296f858 100644 --- a/modules/gaming/minecraft-server.nix +++ b/modules/gaming/minecraft-server.nix @@ -3,7 +3,7 @@ let localPort = 25564; - publicPort = 25565; + publicPort = 49732; rconPort = 25575; rconPassword = "thiscanbeanything"; diff --git a/modules/services/honeypot.nix b/modules/services/honeypot.nix new file mode 100644 index 0000000..b8e79b6 --- /dev/null +++ b/modules/services/honeypot.nix @@ -0,0 +1,75 @@ +{ lib, pkgs, ... }: + +# Currently has some issues that don't make this viable. + +# Taken from: +# https://dataswamp.org/~solene/2022-09-29-iblock-implemented-in-nixos.html + +# You will need to flush all rules when removing: +# https://serverfault.com/questions/200635/best-way-to-clear-all-iptables-rules + +let + + portsToBlock = [ 25545 25565 25570 ]; + portsString = + builtins.concatStringsSep "," (builtins.map builtins.toString portsToBlock); + + # Block IPs for 20 days + expire = 60 * 60 * 24 * 20; + + rules = table: [ + "INPUT -i eth0 -p tcp -m multiport --dports ${portsString} -m state --state NEW -m recent --set" + "INPUT -i eth0 -p tcp -m multiport --dports ${portsString} -m state --state NEW -m recent --update --seconds 10 --hitcount 1 -j SET --add-set ${table} src" + "INPUT -i eth0 -p tcp -m set --match-set ${table} src -j nixos-fw-refuse" + "INPUT -i eth0 -p udp -m set --match-set ${table} src -j nixos-fw-refuse" + ]; + + create-rules = lib.concatStringsSep "\n" + (builtins.map (rule: "iptables -C " + rule + " || iptables -A " + rule) + (rules "blocked") ++ builtins.map + (rule: "ip6tables -C " + rule + " || ip6tables -A " + rule) + (rules "blocked6")); + + delete-rules = lib.concatStringsSep "\n" + (builtins.map (rule: "iptables -C " + rule + " && iptables -D " + rule) + (rules "blocked") ++ builtins.map + (rule: "ip6tables -C " + rule + " && ip6tables -D " + rule) + (rules "blocked6")); + +in { + + networking.firewall = { + + extraPackages = [ pkgs.ipset ]; + # allowedTCPPorts = portsToBlock; + + # Restore ban list when starting up + extraCommands = '' + if test -f /var/lib/ipset.conf + then + ipset restore -! < /var/lib/ipset.conf + else + ipset -exist create blocked hash:ip ${ + if expire > 0 then "timeout ${toString expire}" else "" + } + ipset -exist create blocked6 hash:ip family inet6 ${ + if expire > 0 then "timeout ${toString expire}" else "" + } + fi + ${create-rules} + ''; + + # Save list when shutting down + extraStopCommands = '' + ipset -exist create blocked hash:ip ${ + if expire > 0 then "timeout ${toString expire}" else "" + } + ipset -exist create blocked6 hash:ip family inet6 ${ + if expire > 0 then "timeout ${toString expire}" else "" + } + ipset save > /var/lib/ipset.conf + ${delete-rules} + ''; + }; + +} From 5410afb45bb1ee30985b0b2b5d3cc41b1e5e64a3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 15 Oct 2022 15:29:21 +0000 Subject: [PATCH 051/391] switch to /var/lib for calibre-web --- modules/services/calibre.nix | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 21c9707..d43b9b5 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -1,11 +1,4 @@ -{ config, pkgs, lib, ... }: - -let - - # Must set group owner to calibre-web - libraryPath = "/var/books"; - -in { +{ config, pkgs, lib, ... }: { imports = [ ./caddy.nix ]; @@ -22,7 +15,6 @@ in { enable = true; openFirewall = true; options = { - calibreLibrary = libraryPath; reverseProxyAuth.enable = false; enableBookConversion = true; enableBookUploading = true; @@ -47,22 +39,6 @@ in { }]; }]; - # Create directory and set permissions - systemd.services.calibre-library = { - requiredBy = [ "calibre-web.service" ]; - before = [ "calibre-web.service" ]; - serviceConfig = { - Type = "oneshot"; - User = "root"; - }; - script = '' - mkdir --parents ${libraryPath} - chown -R calibre-web:calibre-web ${libraryPath} - chmod 0775 ${libraryPath} - chmod -R 0640 ${libraryPath}/* - ''; - }; - }; } From e2c351098b8af887bc42b8d4bdd1fb7094cfa3c2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 15 Oct 2022 19:00:37 +0000 Subject: [PATCH 052/391] move cloudflare to separate file --- hosts/oracle/default.nix | 1 + modules/services/caddy.nix | 45 ++++---------------------- modules/services/cloudflare.nix | 56 +++++++++++++++++++++++++++++++++ modules/services/jellyfin.nix | 16 ++-------- modules/services/nextcloud.nix | 35 ++------------------- 5 files changed, 68 insertions(+), 85 deletions(-) create mode 100644 modules/services/cloudflare.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index cb6f239..977b2c9 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -77,6 +77,7 @@ nixpkgs.lib.nixosSystem { ../../modules/services/calibre.nix ../../modules/services/jellyfin.nix ../../modules/services/nextcloud.nix + ../../modules/services/cloudflare.nix ../../modules/services/transmission.nix ../../modules/services/prometheus.nix ../../modules/gaming/minecraft-server.nix diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix index 02c8f00..017abd8 100644 --- a/modules/services/caddy.nix +++ b/modules/services/caddy.nix @@ -5,6 +5,11 @@ type = lib.types.listOf lib.types.attrs; description = "Caddy JSON routes for http servers"; }; + caddyBlocks = lib.mkOption { + type = lib.types.listOf lib.types.attrs; + description = "Caddy JSON error blocks for http servers"; + default = [ ]; + }; }; config = { @@ -16,45 +21,7 @@ apps.http.servers.main = { listen = [ ":443" ]; routes = config.caddyRoutes; - errors.routes = [{ - match = [{ - not = [{ - remote_ip.ranges = [ - - # Cloudflare IPv4: https://www.cloudflare.com/ips-v4 - "173.245.48.0/20" - "103.21.244.0/22" - "103.22.200.0/22" - "103.31.4.0/22" - "141.101.64.0/18" - "108.162.192.0/18" - "190.93.240.0/20" - "188.114.96.0/20" - "197.234.240.0/22" - "198.41.128.0/17" - "162.158.0.0/15" - "104.16.0.0/13" - "104.24.0.0/14" - "172.64.0.0/13" - "131.0.72.0/22" - - # Cloudflare IPv6: https://www.cloudflare.com/ips-v6 - "2400:cb00::/32" - "2606:4700::/32" - "2803:f800::/32" - "2405:b500::/32" - "2405:8100::/32" - "2a06:98c0::/29" - "2c0f:f248::/32" - - ]; - }]; - }]; - handle = [{ - handler = "static_response"; - abort = true; - }]; - }]; + errors.routes = config.caddyBlocks; }; }); diff --git a/modules/services/cloudflare.nix b/modules/services/cloudflare.nix new file mode 100644 index 0000000..a743886 --- /dev/null +++ b/modules/services/cloudflare.nix @@ -0,0 +1,56 @@ +# This module is necessary for hosts that are serving through Cloudflare. + +{ ... }: + +let + + cloudflareIpRanges = [ + + # Cloudflare IPv4: https://www.cloudflare.com/ips-v4 + "173.245.48.0/20" + "103.21.244.0/22" + "103.22.200.0/22" + "103.31.4.0/22" + "141.101.64.0/18" + "108.162.192.0/18" + "190.93.240.0/20" + "188.114.96.0/20" + "197.234.240.0/22" + "198.41.128.0/17" + "162.158.0.0/15" + "104.16.0.0/13" + "104.24.0.0/14" + "172.64.0.0/13" + "131.0.72.0/22" + + # Cloudflare IPv6: https://www.cloudflare.com/ips-v6 + "2400:cb00::/32" + "2606:4700::/32" + "2803:f800::/32" + "2405:b500::/32" + "2405:8100::/32" + "2a06:98c0::/29" + "2c0f:f248::/32" + + ]; + +in { + + imports = [ ./caddy.nix ]; + + config = { + + # Forces Caddy to error if coming from a non-Cloudflare IP + caddyBlocks = [{ + match = [{ not = [{ remote_ip.ranges = cloudflareIpRanges; }]; }]; + handle = [{ + handler = "static_response"; + abort = true; + }]; + }]; + + # Allows Nextcloud to trust Cloudflare IPs + services.nextcloud.config.trustedProxies = cloudflareIpRanges; + + }; +} diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index 0f69c85..b09d36b 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -20,20 +20,8 @@ }]; # Create videos directory, allow anyone in Jellyfin group to manage it - systemd.services.videos-library = { - wantedBy = [ "jellyfin.service" ]; - requiredBy = [ "jellyfin.service" ]; - before = [ "jellyfin.service" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = let videosDirectory = "/var/videos"; - in '' - mkdir --parents --mode 0755 ${videosDirectory} - chown jellyfin:jellyfin ${videosDirectory} - ''; - }; + systemd.tmpfiles.rules = + [ "d /var/lib/jellyfin/library 0775 jellyfin jellyfin" ]; }; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 40a3a2c..9288d24 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -2,8 +2,8 @@ let - adminpassFile = "/var/lib/nextcloud/creds"; - backupS3File = "/var/lib/nextcloud/backup-creds"; + adminpassFile = "${config.services.nextcloud.datadir}/creds"; + backupS3File = "${config.services.nextcloud.datadir}/backup-creds"; in { @@ -45,35 +45,6 @@ in { config = { adminpassFile = adminpassFile; extraTrustedDomains = [ config.nextcloudServer ]; - trustedProxies = [ - - # Cloudflare IPv4: https://www.cloudflare.com/ips-v4 - "173.245.48.0/20" - "103.21.244.0/22" - "103.22.200.0/22" - "103.31.4.0/22" - "141.101.64.0/18" - "108.162.192.0/18" - "190.93.240.0/20" - "188.114.96.0/20" - "197.234.240.0/22" - "198.41.128.0/17" - "162.158.0.0/15" - "104.16.0.0/13" - "104.24.0.0/14" - "172.64.0.0/13" - "131.0.72.0/22" - - # Cloudflare IPv6: https://www.cloudflare.com/ips-v6 - "2400:cb00::/32" - "2606:4700::/32" - "2803:f800::/32" - "2405:b500::/32" - "2405:8100::/32" - "2a06:98c0::/29" - "2c0f:f248::/32" - - ]; }; }; @@ -125,7 +96,7 @@ in { enable = true; settings = { dbs = [{ - path = "/var/lib/nextcloud/data/nextcloud.db"; + path = "${config.services.nextcloud.datadir}/data/nextcloud.db"; replicas = [{ url = "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/nextcloud"; From 69a54b99c85e725dc084f872c2fe9f371a79b047 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 01:32:39 +0000 Subject: [PATCH 053/391] new secrets management system --- apps/encrypt-secret.nix | 19 ++++++ apps/reencrypt-secrets.nix | 27 +++++++++ flake.nix | 7 +++ hosts/public-keys | 4 ++ modules/services/secrets.nix | 97 +++++++++++++++++++++++++++++++ modules/services/transmission.nix | 34 ++++------- modules/shell/age.nix | 28 ++++----- private/transmission.json.age | 15 +++-- 8 files changed, 188 insertions(+), 43 deletions(-) create mode 100644 apps/encrypt-secret.nix create mode 100644 apps/reencrypt-secrets.nix create mode 100644 hosts/public-keys create mode 100644 modules/services/secrets.nix diff --git a/apps/encrypt-secret.nix b/apps/encrypt-secret.nix new file mode 100644 index 0000000..325d942 --- /dev/null +++ b/apps/encrypt-secret.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + + # nix run github:nmasur/dotfiles#encrypt-secret > private/mysecret.age + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "encrypt-secret" '' + printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2 + read -p "Secret: " secret + printf "\nEncrypting...\n\n" 1>&2 + tmpfile=$(mktemp) + echo "''${secret}" > ''${tmpfile} + ${pkgs.age}/bin/age --encrypt --armor --recipients-file ${ + builtins.toString ../hosts/public-keys + } $tmpfile + rm $tmpfile + ''); + +} diff --git a/apps/reencrypt-secrets.nix b/apps/reencrypt-secrets.nix new file mode 100644 index 0000000..f1c2c2d --- /dev/null +++ b/apps/reencrypt-secrets.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: { + + # nix run github:nmasur/dotfiles#reencrypt-secrets ./private + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "reencrypt-secrets" '' + if [ $# -eq 0 ]; then + echo "Must provide directory to reencrypt." + exit 1 + fi + encrypted=$1 + for encryptedfile in ''${1}/*; do + tmpfile=$(mktemp) + echo "Decrypting ''${encryptedfile}..." + ${pkgs.age}/bin/age --decrypt \ + --identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile + echo "Encrypting ''${encryptedfile}..." + ${pkgs.age}/bin/age --encrypt --armor --recipients-file ${ + builtins.toString ../hosts/public-keys + } $tmpfile > $encryptedfile + rm $tmpfile + done + echo "Finished." + ''); + +} diff --git a/flake.nix b/flake.nix index 04c5811..1a9709c 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,13 @@ # Load the SSH key for this machine loadkey = import ./apps/loadkey.nix { inherit pkgs; }; + # Encrypt secret for all machines + encrypt-secret = import ./apps/encrypt-secret.nix { inherit pkgs; }; + + # Re-encrypt secrets for all machines + reencrypt-secrets = + import ./apps/reencrypt-secrets.nix { inherit pkgs; }; + # Connect machine metrics to Netdata Cloud netdata = import ./apps/netdata-cloud.nix { inherit pkgs; }; diff --git a/hosts/public-keys b/hosts/public-keys new file mode 100644 index 0000000..74beb04 --- /dev/null +++ b/hosts/public-keys @@ -0,0 +1,4 @@ +# Scan hosts: ssh-keyscan -t ed25519 + +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s noah +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHVknmPi7sG6ES0G0jcsvebzKGWWaMfJTYgvOue6EULI oracle.masu.rs diff --git a/modules/services/secrets.nix b/modules/services/secrets.nix new file mode 100644 index 0000000..79187b6 --- /dev/null +++ b/modules/services/secrets.nix @@ -0,0 +1,97 @@ +# Secrets management method taken from here: +# https://xeiaso.net/blog/nixos-encrypted-secrets-2021-01-20 + +# In my case, I pre-encrypt my secrets and commit them to git. + +{ config, pkgs, lib, ... }: { + + options = { + + identityFile = lib.mkOption { + type = lib.types.str; + description = "Path to existing identity file."; + default = "/etc/ssh/ssh_host_ed25519_key"; + }; + + # secretsDirectory = lib.mkOption { + # type = lib.types.str; + # description = "Default path to place secrets."; + # default = "/var/lib/private"; + # }; + + secrets = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options = { + source = lib.mkOption { + type = lib.types.path; + description = "Path to encrypted secret."; + }; + dest = lib.mkOption { + type = lib.types.str; + description = "Resulting path for decrypted secret."; + }; + owner = lib.mkOption { + default = "root"; + type = lib.types.str; + description = "User to own the secret."; + }; + group = lib.mkOption { + default = "root"; + type = lib.types.str; + description = "Group to own the secret."; + }; + permissions = lib.mkOption { + default = "0400"; + type = lib.types.str; + description = "Permissions expressed as octal."; + }; + }; + }); + description = "Set of secrets to decrypt to disk."; + default = { }; + }; + + }; + + config = { + + # Create a default directory to place secrets + + # systemd.tmpfiles.rules = [ "d ${config.secretsDirectory} 0750 root wheel" ]; + + # Declare oneshot service to decrypt secret using SSH host key + # - Requires that the secret is already encrypted for the host + # - Encrypt secrets: nix run github:nmasur/dotfiles#encrypt-secret + + systemd.services = lib.mapAttrs' (name: attrs: { + name = "${name}-secret"; + value = { + + description = "Decrypt secret for ${name}"; + wantedBy = [ "multi-user.target" ]; + serviceConfig.Type = "oneshot"; + script = '' + ${pkgs.age}/bin/age --decrypt \ + --identity ${config.identityFile} \ + --output ${attrs.dest} \ + ${attrs.source} + + chown '${attrs.owner}':'${attrs.group}' '${attrs.dest}' + chmod '${attrs.permissions}' '${attrs.dest}' + ''; + + }; + }) config.secrets; + + # Example declaration + # config.secrets.my-secret = { + # source = ../../private/my-secret.age; + # dest = "/var/lib/private/my-secret"; + # owner = "my-app"; + # group = "my-app"; + # permissions = "0440"; + # }; + + }; + +} diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 0a6f9dd..f35088d 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -1,10 +1,6 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, ... }: { -let credentialsFile = "/var/lib/private/transmission.json"; - -in { - - imports = [ ./wireguard.nix ]; + imports = [ ./wireguard.nix ./secrets.nix ]; options = { transmissionServer = lib.mkOption { @@ -33,14 +29,14 @@ in { rpc-whitelist = "127.0.0.1,${vpnIp}"; rpc-whitelist-enabled = true; }; - credentialsFile = credentialsFile; + credentialsFile = config.secrets.transmission.dest; }; # Bind transmission to wireguard namespace systemd.services.transmission = { bindsTo = [ "netns@${namespace}.service" ]; - requires = [ "network-online.target" ]; - after = [ "wireguard-wg0.service" ]; + requires = [ "network-online.target" "transmission-secret.service" ]; + after = [ "wireguard-wg0.service" "transmission-secret.service" ]; unitConfig.JoinsNamespaceOf = "netns@${namespace}.service"; serviceConfig.NetworkNamespacePath = "/var/run/netns/${namespace}"; }; @@ -71,21 +67,11 @@ in { }; # Create credentials file for transmission - systemd.services.transmission-creds = { - requiredBy = [ "transmission.service" ]; - before = [ "transmission.service" ]; - serviceConfig = { Type = "oneshot"; }; - script = '' - if [ ! -f "${credentialsFile}" ]; then - mkdir --parents ${builtins.dirOf credentialsFile} - ${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - --output ${credentialsFile} \ - ${builtins.toString ../../private/transmission.json.age} - chown transmission:transmission ${credentialsFile} - chmod 0700 ${credentialsFile} - fi - ''; + secrets.transmission = { + source = ../../private/transmission.json.age; + dest = "/var/lib/private/transmission.json"; + owner = "transmission"; + group = "transmission"; }; }; diff --git a/modules/shell/age.nix b/modules/shell/age.nix index 87cf6df..7dcc33b 100644 --- a/modules/shell/age.nix +++ b/modules/shell/age.nix @@ -1,25 +1,25 @@ { config, pkgs, lib, ... }: { options = { - identityFile = lib.mkOption { - type = lib.types.str; - description = "Path to SSH key for age"; - default = "${config.homePath}/.ssh/id_ed25519"; - }; + # identityFile = lib.mkOption { + # type = lib.types.str; + # description = "Path to SSH key for age"; + # default = "${config.homePath}/.ssh/id_ed25519"; + # }; }; config = { home-manager.users.${config.user}.home.packages = with pkgs; [ age ]; - system.activationScripts.age.text = '' - if [ ! -f "${config.identityFile}" ]; then - $DRY_RUN_CMD echo -e \nEnter the seed phrase for your SSH key...\n - $DRY_RUN_CMD echo -e \nThen press ^D when complete.\n\n - $DRY_RUN_CMD ${pkgs.melt}/bin/melt restore ${config.identityFile} - $DRY_RUN_CMD chown ${config.user}:wheel ${config.identityFile}* - $DRY_RUN_CMD echo -e \n\nContinuing activation.\n\n - fi - ''; + # system.activationScripts.age.text = '' + # if [ ! -f "${config.identityFile}" ]; then + # $DRY_RUN_CMD echo -e \nEnter the seed phrase for your SSH key...\n + # $DRY_RUN_CMD echo -e \nThen press ^D when complete.\n\n + # $DRY_RUN_CMD ${pkgs.melt}/bin/melt restore ${config.identityFile} + # $DRY_RUN_CMD chown ${config.user}:wheel ${config.identityFile}* + # $DRY_RUN_CMD echo -e \n\nContinuing activation.\n\n + # fi + # ''; }; } diff --git a/private/transmission.json.age b/private/transmission.json.age index a98cddd..091ed0c 100644 --- a/private/transmission.json.age +++ b/private/transmission.json.age @@ -1,5 +1,10 @@ -age-encryption.org/v1 --> ssh-ed25519 MgHaOw PAAWnpc5bJ5S972U+L6YgHpI2a7aqwxWaNZrvQIODVg -A6zRWD6TmlVb8b5J3gdMf3JAeHIHgUQA3C8PpR8GveQ ---- xP8vbUGtTlvaZ0K2J0+J0ICoL9gvCbhQg6GxG8ZYCS0 -75L2cJĀe,ݝTn$Mi4Yi[! ŁL%(iF;6ԊjO \ No newline at end of file +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBSYUU2 +OWp1ZDRLVTJrR1k3SVdXZnRPN3RUNDY5RFM2WEZaTzRmdU1zSWdrCjV1VHpNMG81 +VHA4LzdsN3FpOUNoTGNlWmlHS3E4dTVvWTVoZHJMSlNYTHMKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIDVjM1JmclgxQThKcU1XQWptWmN0MjlKU1NvMEpwMnYyd3Y4czBT +RTVkQ0UKc0pOYkRxZldsWnloQnBYMWk1eFU0M3R5SkZVTUYyaldIcENONE1PWVJv +NAotLS0gclZDQndaREZpZ2Z0R0d0alBPeW1tZFVOVHhSaHNlQTRXdTRoZmFDUFFK +SQqueOUzTFuhSryWW4Do+NAUcq2YdOtN8gmP5Zcp1oMe/9+JIs6Upjsc3eWn+dSA +7QwbGlTyd6D0+PLJxHA18Xfgpj5owGeTDtwykFPgdO1BjE8C3KlgzUfN +-----END AGE ENCRYPTED FILE----- From 0f112ea16b4f4a3afe3a9fe7f4919995785dbe63 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 03:18:58 +0000 Subject: [PATCH 054/391] reencrypt secrets and fix nextcloud backups --- modules/services/backups.nix | 46 ++++++++++++++++++ modules/services/nextcloud.nix | 76 +++++++----------------------- modules/services/secrets.nix | 12 ++--- modules/services/transmission.nix | 2 +- modules/services/wireguard.nix | 34 ++----------- private/backup.age | 16 ++++--- private/mailpass.age | 15 ++++-- private/nextcloud.age | Bin 246 -> 552 bytes private/wireguard.age | 15 ++++-- 9 files changed, 104 insertions(+), 112 deletions(-) create mode 100644 modules/services/backups.nix diff --git a/modules/services/backups.nix b/modules/services/backups.nix new file mode 100644 index 0000000..373387c --- /dev/null +++ b/modules/services/backups.nix @@ -0,0 +1,46 @@ +{ config, pkgs, lib, ... }: { + + options = { + + backupS3 = { + endpoint = lib.mkOption { + type = lib.types.str; + description = "S3 endpoint for backups"; + }; + bucket = lib.mkOption { + type = lib.types.str; + description = "S3 bucket for backups"; + }; + accessKeyId = lib.mkOption { + type = lib.types.str; + description = "S3 access key ID for backups"; + }; + }; + + }; + + config = { + + secrets.backup = { + source = ../../private/backup.age; + dest = "${config.secretsDirectory}/backup"; + }; + + # # Backup library to object storage + # services.restic.backups.calibre = { + # user = "calibre-web"; + # repository = + # "s3://${config.backupS3.endpoint}/${config.backupS3.bucket}/calibre"; + # paths = [ + # "/var/books" + # "/var/lib/calibre-web/app.db" + # "/var/lib/calibre-web/gdrive.db" + # ]; + # initialize = true; + # timerConfig = { OnCalendar = "00:05:00"; }; + # environmentFile = backupS3File; + # }; + + }; + +} diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 9288d24..60bcbdd 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -1,13 +1,6 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, ... }: { -let - - adminpassFile = "${config.services.nextcloud.datadir}/creds"; - backupS3File = "${config.services.nextcloud.datadir}/backup-creds"; - -in { - - imports = [ ./caddy.nix ../shell/age.nix ]; + imports = [ ./caddy.nix ./secrets.nix ./backups.nix ]; options = { @@ -16,22 +9,6 @@ in { description = "Hostname for Nextcloud"; }; - # Options for backup - backupS3 = { - endpoint = lib.mkOption { - type = lib.types.str; - description = "S3 endpoint for backups"; - }; - bucket = lib.mkOption { - type = lib.types.str; - description = "S3 bucket for backups"; - }; - accessKeyId = lib.mkOption { - type = lib.types.str; - description = "S3 access key ID for backups"; - }; - }; - }; config = { @@ -43,7 +20,7 @@ in { hostName = "localhost"; maxUploadSize = "50G"; config = { - adminpassFile = adminpassFile; + adminpassFile = config.secrets.nextcloud.dest; extraTrustedDomains = [ config.nextcloudServer ]; }; }; @@ -54,6 +31,7 @@ in { port = 8080; }]; + # Point Caddy to Nginx caddyRoutes = [{ match = [{ host = [ config.nextcloudServer ]; }]; handle = [{ @@ -63,22 +41,16 @@ in { }]; # Create credentials file for nextcloud - systemd.services.nextcloud-creds = { + secrets.nextcloud = { + source = ../../private/nextcloud.age; + dest = "${config.secretsDirectory}/nextcloud"; + owner = "nextcloud"; + group = "nextcloud"; + permissions = "0440"; + }; + systemd.services.nextcloud-secret = { requiredBy = [ "nextcloud-setup.service" ]; before = [ "nextcloud-setup.service" ]; - serviceConfig = { - Type = "oneshot"; - User = "root"; - }; - script = '' - mkdir --parents $(dirname ${adminpassFile}) - ${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - --output ${adminpassFile} \ - ${builtins.toString ../../private/nextcloud.age} - chown nextcloud:nextcloud ${adminpassFile} - chmod 0700 ${adminpassFile} - ''; }; ## Backup config @@ -103,30 +75,14 @@ in { }]; }]; }; - environmentFile = backupS3File; + environmentFile = config.secrets.backup.dest; }; # Don't start litestream unless nextcloud is up systemd.services.litestream = { - after = [ "phpfpm-nextcloud.service" ]; - requires = [ "phpfpm-nextcloud.service" ]; - environment.LITESTREAM_ACCESS_KEY_ID = config.backupS3.accessKeyId; - }; - - # Create credentials file for litestream - systemd.services.litestream-s3 = { - requiredBy = [ "litestream.service" ]; - before = [ "litestream.service" ]; - serviceConfig = { Type = "oneshot"; }; - script = '' - echo \ - LITESTREAM_SECRET_ACCESS_KEY=$(${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - ${builtins.toString ../../private/backup.age} \ - ) > ${backupS3File} - chown litestream:litestream ${backupS3File} - chmod 0700 ${backupS3File} - ''; + after = [ "phpfpm-nextcloud.service" "backup-secret.service" ]; + requires = [ "phpfpm-nextcloud.service" "backup-secret.service" ]; + environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; }; }; diff --git a/modules/services/secrets.nix b/modules/services/secrets.nix index 79187b6..2583c65 100644 --- a/modules/services/secrets.nix +++ b/modules/services/secrets.nix @@ -13,11 +13,11 @@ default = "/etc/ssh/ssh_host_ed25519_key"; }; - # secretsDirectory = lib.mkOption { - # type = lib.types.str; - # description = "Default path to place secrets."; - # default = "/var/lib/private"; - # }; + secretsDirectory = lib.mkOption { + type = lib.types.str; + description = "Default path to place secrets."; + default = "/var/private"; + }; secrets = lib.mkOption { type = lib.types.attrsOf (lib.types.submodule { @@ -57,7 +57,7 @@ # Create a default directory to place secrets - # systemd.tmpfiles.rules = [ "d ${config.secretsDirectory} 0750 root wheel" ]; + systemd.tmpfiles.rules = [ "d ${config.secretsDirectory} 0755 root wheel" ]; # Declare oneshot service to decrypt secret using SSH host key # - Requires that the secret is already encrypted for the host diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index f35088d..7fd56ad 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -69,7 +69,7 @@ # Create credentials file for transmission secrets.transmission = { source = ../../private/transmission.json.age; - dest = "/var/lib/private/transmission.json"; + dest = "${config.secretsDirectory}/transmission.json"; owner = "transmission"; group = "transmission"; }; diff --git a/modules/services/wireguard.nix b/modules/services/wireguard.nix index 4b437b9..9b1003d 100644 --- a/modules/services/wireguard.nix +++ b/modules/services/wireguard.nix @@ -1,14 +1,6 @@ { config, pkgs, lib, ... }: { - options.networking.wireguard = { - - encryptedPrivateKey = lib.mkOption { - type = lib.types.path; - description = "Nix path to age-encrypted client private key"; - default = ../../private/wireguard.age; - }; - - }; + imports = [ ./secrets.nix ]; config = { @@ -19,7 +11,7 @@ # Establishes identity of this machine generatePrivateKeyFile = false; - privateKeyFile = "/private/wireguard/wg0"; + privateKeyFile = config.secrets.wireguard.dest; # Move to network namespace for isolating programs interfaceNamespace = "wg"; @@ -42,25 +34,9 @@ }; # Create private key file for wireguard - systemd.services.wireguard-private-key = { - wantedBy = [ "wireguard-wg0.service" ]; - requiredBy = [ "wireguard-wg0.service" ]; - before = [ "wireguard-wg0.service" ]; - serviceConfig = { Type = "oneshot"; }; - script = let - encryptedPrivateKey = config.networking.wireguard.encryptedPrivateKey; - privateKeyFile = - config.networking.wireguard.interfaces.wg0.privateKeyFile; - in '' - mkdir --parents --mode 0755 ${builtins.dirOf privateKeyFile} - if [ ! -f "${privateKeyFile}" ]; then - ${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - --output ${privateKeyFile} \ - ${builtins.toString encryptedPrivateKey} - chmod 0700 ${privateKeyFile} - fi - ''; + secrets.wireguard = { + source = ../../private/wireguard.age; + dest = "${config.secretsDirectory}/wireguard"; }; }; diff --git a/private/backup.age b/private/backup.age index bc1483a..497ddf6 100644 --- a/private/backup.age +++ b/private/backup.age @@ -1,6 +1,10 @@ -age-encryption.org/v1 --> ssh-ed25519 MgHaOw 2y5C1sRq3NZqmfGBiPgMS7qcU5v+70wri5xkXbceaHM -zyd7b+OuVi3rxxUEm+QW/80M80SSKaebOwOioRjnYak ---- yZQxxjYYNouD5wnEj+qNjUSrRU01hXvWUuax4C252i8 -/2*MD^ӜOQ -5 ssh-ed25519 MgHaOw 8h/ESNjn0gknNXoHM34UobHzPgmRunoP97H+KHOuGQM -qowH+6TlCRECGCscRgKx6kswY+PZezYUD6E+x9e+5pM ---- kFj1JzRdh/D13Uq9aNTzMJIFysEE+kzzthjewOIR2+o -Ȳ6}rCz >&=jW ^Wl!"}MS8=xm =ЇL \ No newline at end of file +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBIRnEy +am1HTXptMmpSTjZQa2hQSUxNUU1rdXlod3U3bVZ0VGxQVlE2WldBClg0K3k5MDZH +NFlPdHI0VnZSZE9DTTNMeDdldUpFQ3V0V0k0RnRIZHFhdzAKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIFlxZFpqNU5kNVY2VUk0Um0zZ1d1M2FlRkYvV1BoTEFSNjZ2Vk9I +QTVHM0UKY2gvVU9wckVUNEFwdUwyVFJZUGwxOFFKYm12cUlFTEVrb3IvcXI3TnND +UQotLS0gMHdaajFjV2ozd0g5dWN5YkhiU2NBVWZVSU00aVIzY0VKYjJleVlQTUdX +QQo7rH6kOTRFP43U/qiBOCHx+hBGlaODFRS1CgzkuqfMOq8PM28RsIN+l3sbwjxE +W8chE/A0EChjIDtfYTMgsN3cYg== +-----END AGE ENCRYPTED FILE----- diff --git a/private/nextcloud.age b/private/nextcloud.age index 77526b6596398552bc8d57e1c7b76f2b79683152..e0d8ca807bb1ab6e10f098168c52f6fed95dcc98 100644 GIT binary patch literal 552 zcmZ{iyLO{607QGf!hMdDVv7LcWl(~Ughhve#YVhhL%@7}yxZ@z)6CqN{r)Kv zxjx>#yJ&~7MZ_mX_RjG`^w--fA}!l6<+IQNqwvUhR`vO;1%0TA)w+Tg-@{vO!8Wsf zh$%9B1pCBwKFfzWmvZfuY-3PxeibY;Q_iXAU{ZPGcizWF1jNGKK^1M;VwEfcO!p!k zO{*zE)=goiP8X#_(Jhun%mLacAS0Kxadrn-cqPRf7hGl|-;kbr1ms(N45?lh8Xlgh zWz;aJL{!%4simAj;ydkEj(jy{xQ`kFDR2-z1%8Br^n*D8J7s#(2J4wQeJrPxrH4gf zPTMgik0B&Wo~{FSB0Z5~UZ&FnKUt(+**uHg;%)#XI|QsBLDXQQ>iL~@he64fVG0va zr>s;fN>uL3M@6$IP(0^-bW7Uo$h$(PF#8~A?O1=YlLiBf0*M>BDaCTT&JSVL-$C_C z$yMur1_K|*h1Ge}u^GjBOeN=i{SQ)XsoI8Rr4R99_LWqK=GFii?FMNczqOJ!kG zT2(nQc~fd)bY^KwD?v7QVNyXsPi#U?LQYv@No6x-MNJAVEiE8tN^fCrQaEsHPjyo< zVp>aVNJcU?S#f%1OKNmyK|ym~%Qc(&e#L$H*Wq|4w@}KwsI6eqsKL%(O w9)AbuS8smQol&)kjaymIZ%)-gKBGgdSdg$w#39g+>lk2Ly9xs!ow8X7n=av2v;Y7A diff --git a/private/wireguard.age b/private/wireguard.age index a055a02..17f8112 100644 --- a/private/wireguard.age +++ b/private/wireguard.age @@ -1,5 +1,10 @@ -age-encryption.org/v1 --> ssh-ed25519 MgHaOw lG6VtLpEU/33egpB9WqJiulVdL3K5a2IGjekIu6HtSI -VsAfCbtQuHU9tptKQR4buD3ydwb89aSbUVdEoetU1gc ---- kts74pY8NdQh4pTlMT3NTHxU0qnA0txwQKH5FkQCdXA -S8A 0`0$,1*/HV ZtWBC[ Date: Sun, 16 Oct 2022 03:19:41 +0000 Subject: [PATCH 055/391] backups requires secrets --- modules/services/backups.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/services/backups.nix b/modules/services/backups.nix index 373387c..57503b6 100644 --- a/modules/services/backups.nix +++ b/modules/services/backups.nix @@ -1,5 +1,7 @@ { config, pkgs, lib, ... }: { + imports = [ ./secrets.nix ]; + options = { backupS3 = { From e1e27ca065bb4178b8d561648f85087779d328bb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 03:47:21 +0000 Subject: [PATCH 056/391] backup calibre data --- hosts/oracle/default.nix | 2 +- modules/services/backups.nix | 4 ++++ modules/services/calibre.nix | 31 ++++++++++++++++++++++++++++++- modules/services/nextcloud.nix | 2 +- private/backup.age | 16 ++++++++-------- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 977b2c9..382e7cc 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -32,7 +32,7 @@ nixpkgs.lib.nixosSystem { backupS3 = { endpoint = "s3.us-west-002.backblazeb2.com"; bucket = "noahmasur-backup"; - accessKeyId = "0026b0e73b2e2c80000000004"; + accessKeyId = "0026b0e73b2e2c80000000005"; }; # Grant access to Jellyfin directories from Nextcloud diff --git a/modules/services/backups.nix b/modules/services/backups.nix index 57503b6..d63e3dd 100644 --- a/modules/services/backups.nix +++ b/modules/services/backups.nix @@ -23,9 +23,13 @@ config = { + users.groups.backup = { }; + secrets.backup = { source = ../../private/backup.age; dest = "${config.secretsDirectory}/backup"; + group = "backup"; + permissions = "0440"; }; # # Backup library to object storage diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index d43b9b5..dc29b8d 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -1,6 +1,6 @@ { config, pkgs, lib, ... }: { - imports = [ ./caddy.nix ]; + imports = [ ./caddy.nix ./backups.nix ]; options = { bookServer = lib.mkOption { @@ -39,6 +39,35 @@ }]; }]; + # Run a backup on a schedule + systemd.timers.calibre-backup = { + timerConfig = { + OnCalendar = "*-*-* 00:00:00"; # Once per day + Unit = "calibre-backup.service"; + }; + wantedBy = [ "timers.target" ]; + }; + + # Backup Calibre data to object storage + systemd.services.calibre-backup = + let libraryPath = "/var/lib/calibre-web"; # Default location + in { + description = "Backup Calibre data"; + environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + serviceConfig = { + Type = "oneshot"; + User = "calibre-web"; + Group = "backup"; + EnvironmentFile = config.secrets.backup.dest; + }; + script = '' + ${pkgs.awscli2}/bin/aws s3 sync \ + ${libraryPath}/ \ + s3://${config.backupS3.bucket}/calibre/ \ + --endpoint-url=https://${config.backupS3.endpoint} + ''; + }; + }; } diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 60bcbdd..13f6aeb 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -60,7 +60,7 @@ lib.mkForce "0770"; # Allow litestream and nextcloud to share a sqlite database - users.users.litestream.extraGroups = [ "nextcloud" ]; + users.users.litestream.extraGroups = [ "nextcloud" "backup" ]; users.users.nextcloud.extraGroups = [ "litestream" ]; # Backup sqlite database with litestream diff --git a/private/backup.age b/private/backup.age index 497ddf6..0a9a7e8 100644 --- a/private/backup.age +++ b/private/backup.age @@ -1,10 +1,10 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBuMUg4 -TG5Oa1U5WERGOWJibkRZRVJwZGdEZmRsSVBraHdVYTJwbGpNL1VnCjRYaW1nTUR0 -cjR2NHJ1V1lhRHp4a2VOekVTZVl5Rk5CcG1heHhsR2M5SHMKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIHhEN3o1NzNTTVIvZG1VcERJQitkRk4vTmtFQk9SVUVJQUVOdVY2 -YWoxM1UKVVVMWTYzKzE4ZjVDWitGNkUvR2U1Z1VJdVdqOWhWZVAxNWFOaFZvZGpS -OAotLS0gWlU2TEY0TFZiM3VCM0hWcDAvQlQzTjE3MkZSOGNXaUhDdVQzL2pVRzlT -VQoP0xMzUx0ozRvXFrNfFNyqwzUoHl7GM1P6VFjjDjuMkuWtQ/+V6DV/rGlXDKJ9 -jidhm8Y0hbjL6cbQrolUSgHSzG5CPD/4pb3zmxTZ9ol7cQuR4PbnPQ== +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBmVEo2 +bExsZERhYi9vVXMxVThRK2w3dFR4UlZVcGlsWUFPM3pReTQwaW5ZCjQ5Z3g3amZC +bWUwWkdKTStVbFpwMmdwK3pQQU5CeE5tMVNHbXI1UkdCTFUKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIE9sTG1lOHIyVGdLNWtJRTZtdGNWWEFsTTJ5bE1HS1V2MEdKeGNN +WFMyV28KVlRHdDg5SGFadVlJempKWkp6eEp6TkhINnl0R0xDL0J0WXByclpFWE5I +VQotLS0gVVhaUDZLTy8xS3hKOVliSlpuTEY2Q2xOQUEvblBtUG9Vb0I5ZE1oOUZ1 +VQr18Jwx6XDa7bwq0QWT6NdIFzqNUHWhDyUvS9twncFsr0yEAUDQd2XLtE+Vc8T9 +Z7y/C8Ct5+duqd6YaeqROJz5zVj0NnI0lshirBl89PQWF9ihp4V4Hw== -----END AGE ENCRYPTED FILE----- From 084e832039191d026871174a4d190b8f5caa8226 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 14:20:50 +0000 Subject: [PATCH 057/391] wsl fixes --- hosts/common.nix | 46 +++++++++++++++++-------------- hosts/desktop/default.nix | 1 + hosts/macbook/default.nix | 1 + hosts/wsl/default.nix | 1 + modules/mail/himalaya.nix | 9 +++--- modules/neovim/lua/packer/lsp.lua | 3 +- modules/services/secrets.nix | 6 ---- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/hosts/common.nix b/hosts/common.nix index 2217f62..2beb87b 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -21,6 +21,11 @@ if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads"; }; }; + identityFile = lib.mkOption { + type = lib.types.str; + description = "Path to existing identity file."; + default = "/etc/ssh/ssh_host_ed25519_key"; + }; gui = { enable = mkEnableOption { description = "Enable graphics"; @@ -39,6 +44,7 @@ else "/home/${config.user}"); }; + dotfilesPath = mkOption { type = types.path; description = "Path of dotfiles repository."; @@ -55,33 +61,31 @@ }; }; - config = - let stateVersion = "22.11"; - in - { + config = let stateVersion = "22.11"; + in { - # Enable features in Nix commands - nix.extraOptions = "experimental-features = nix-command flakes"; + # Enable features in Nix commands + nix.extraOptions = "experimental-features = nix-command flakes"; - # Basic common system packages for all devices - environment.systemPackages = with pkgs; [ git vim wget curl ]; + # Basic common system packages for all devices + environment.systemPackages = with pkgs; [ git vim wget curl ]; - # Use the system-level nixpkgs instead of Home Manager's - home-manager.useGlobalPkgs = true; + # Use the system-level nixpkgs instead of Home Manager's + home-manager.useGlobalPkgs = true; - # Install packages to /etc/profiles instead of ~/.nix-profile, useful when - # using multiple profiles for one user - home-manager.useUserPackages = true; + # Install packages to /etc/profiles instead of ~/.nix-profile, useful when + # using multiple profiles for one user + home-manager.useUserPackages = true; - # Allow specified unfree packages (identified elsewhere) - # Retrieves package object based on string name - nixpkgs.config.allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) config.unfreePackages; + # Allow specified unfree packages (identified elsewhere) + # Retrieves package object based on string name + nixpkgs.config.allowUnfreePredicate = pkg: + builtins.elem (lib.getName pkg) config.unfreePackages; - # Pin a state version to prevent warnings - home-manager.users.${config.user}.home.stateVersion = stateVersion; - home-manager.users.root.home.stateVersion = stateVersion; + # Pin a state version to prevent warnings + home-manager.users.${config.user}.home.stateVersion = stateVersion; + home-manager.users.root.home.stateVersion = stateVersion; - }; + }; } diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 35d821a..ace5cad 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -12,6 +12,7 @@ nixpkgs.lib.nixosSystem { nixpkgs.overlays = [ nur.overlay ]; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; + identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gaming.steam = true; gaming.leagueoflegends = true; gaming.legendary = true; diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 8d58f1e..8d3dcf4 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -12,6 +12,7 @@ darwin.lib.darwinSystem { }) home-manager.darwinModules.home-manager { + identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = true; colorscheme = (import ../../modules/colorscheme/gruvbox); mailUser = globals.user; diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index a2e37a5..95cc9f3 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -12,6 +12,7 @@ nixpkgs.lib.nixosSystem { networking.hostName = "wsl"; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; + identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = false; colorscheme = (import ../../modules/colorscheme/gruvbox); passwordHash = diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 7e7363b..bca7cbf 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -75,11 +75,10 @@ }; mu.enable = false; notmuch.enable = false; - passwordCommand = '' - ${pkgs.age}/bin/age --decrypt \ - --identity ${config.identityFile} \ - ${builtins.toString ../../private/mailpass.age} - ''; + passwordCommand = + "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ + builtins.toString ../../private/mailpass.age + }"; smtp = { host = "smtp.purelymail.com"; port = 465; diff --git a/modules/neovim/lua/packer/lsp.lua b/modules/neovim/lua/packer/lsp.lua index 991f2bd..9316d49 100644 --- a/modules/neovim/lua/packer/lsp.lua +++ b/modules/neovim/lua/packer/lsp.lua @@ -14,8 +14,7 @@ M.packer = function(use) return vim.fn.executable(program) == 1 end - local capabilities = - require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) + local capabilities = require("cmp_nvim_lsp").default_capabilities() if on_path("lua-language-server") then require("lspconfig").sumneko_lua.setup({ capabilities = capabilities, diff --git a/modules/services/secrets.nix b/modules/services/secrets.nix index 2583c65..d596c70 100644 --- a/modules/services/secrets.nix +++ b/modules/services/secrets.nix @@ -7,12 +7,6 @@ options = { - identityFile = lib.mkOption { - type = lib.types.str; - description = "Path to existing identity file."; - default = "/etc/ssh/ssh_host_ed25519_key"; - }; - secretsDirectory = lib.mkOption { type = lib.types.str; description = "Default path to place secrets."; From 89a95445e1b321d0455c7c0d3f71a60c89174401 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 14:25:47 +0000 Subject: [PATCH 058/391] remove age and loadkey module --- modules/shell/age.nix | 25 ------------------------- modules/shell/default.nix | 1 - modules/shell/utilities.nix | 1 + 3 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 modules/shell/age.nix diff --git a/modules/shell/age.nix b/modules/shell/age.nix deleted file mode 100644 index 7dcc33b..0000000 --- a/modules/shell/age.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ config, pkgs, lib, ... }: { - - options = { - # identityFile = lib.mkOption { - # type = lib.types.str; - # description = "Path to SSH key for age"; - # default = "${config.homePath}/.ssh/id_ed25519"; - # }; - }; - - config = { - home-manager.users.${config.user}.home.packages = with pkgs; [ age ]; - - # system.activationScripts.age.text = '' - # if [ ! -f "${config.identityFile}" ]; then - # $DRY_RUN_CMD echo -e \nEnter the seed phrase for your SSH key...\n - # $DRY_RUN_CMD echo -e \nThen press ^D when complete.\n\n - # $DRY_RUN_CMD ${pkgs.melt}/bin/melt restore ${config.identityFile} - # $DRY_RUN_CMD chown ${config.user}:wheel ${config.identityFile}* - # $DRY_RUN_CMD echo -e \n\nContinuing activation.\n\n - # fi - # ''; - }; - -} diff --git a/modules/shell/default.nix b/modules/shell/default.nix index ac60e9b..9359d15 100644 --- a/modules/shell/default.nix +++ b/modules/shell/default.nix @@ -1,6 +1,5 @@ { ... }: { imports = [ - ./age.nix ./charm.nix ./direnv.nix ./fish diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index 68c4583..d5d09e2 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -32,6 +32,7 @@ in { dig # DNS lookup lf # File viewer whois # Lookup IPs + age # Encryption ]; programs.zoxide.enable = true; # Shortcut jump command From 7bca2775d1017edced97b64dda026f85e29ba30f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 14:44:42 +0000 Subject: [PATCH 059/391] don't start stop-minecraft timer on rebuild --- modules/gaming/minecraft-server.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/gaming/minecraft-server.nix b/modules/gaming/minecraft-server.nix index 296f858..822cdab 100644 --- a/modules/gaming/minecraft-server.nix +++ b/modules/gaming/minecraft-server.nix @@ -101,7 +101,6 @@ in { OnCalendar = "*-*-* *:*:0/20"; # Every 20 seconds Unit = "stop-minecraft.service"; }; - wantedBy = [ "timers.target" ]; }; # If no players are connected, then stop services and prepare to resume again From 6f67e31723e439cdb320d11a31ed4de08ec8ecba Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 18:10:11 +0000 Subject: [PATCH 060/391] working vaultwarden haven't tested websockets --- hosts/oracle/default.nix | 2 ++ modules/services/vaultwarden.nix | 36 ++++++++++++++++++++++++++++---- private/vaultwarden.age | 11 ++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 private/vaultwarden.age diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 382e7cc..8f48abf 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -22,6 +22,7 @@ nixpkgs.lib.nixosSystem { nextcloudServer = "cloud.masu.rs"; transmissionServer = "download.masu.rs"; metricsServer = "metrics.masu.rs"; + vaultwardenServer = "vault.masu.rs"; # Disable passwords, only use SSH key passwordHash = null; @@ -80,6 +81,7 @@ nixpkgs.lib.nixosSystem { ../../modules/services/cloudflare.nix ../../modules/services/transmission.nix ../../modules/services/prometheus.nix + ../../modules/services/vaultwarden.nix ../../modules/gaming/minecraft-server.nix ]; } diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index e452281..8acb438 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options = { @@ -13,12 +13,40 @@ services.vaultwarden = { enable = true; config = { - DOMAIN = config.vaultwardenServer; + DOMAIN = "https://${config.vaultwardenServer}"; SIGNUPS_ALLOWED = false; + SIGNUPS_VERIFY = true; + INVITATIONS_ALLOWED = true; + WEB_VAULT_ENABLED = true; + ROCKET_ADDRESS = "127.0.0.1"; + ROCKET_PORT = 8222; + WEBSOCKET_ENABLED = true; + WEBSOCKET_ADDRESS = "0.0.0.0"; + WEBSOCKET_PORT = 3012; + LOGIN_RATELIMIT_SECONDS = 60; + LOGIN_RATELIMIT_MAX_BURST = 10; + ADMIN_RATELIMIT_SECONDS = 300; + ADMIN_RATELIMIT_MAX_BURST = 3; }; - environmentFile = null; + environmentFile = config.secrets.vaultwarden.dest; dbBackend = "sqlite"; }; - }; + + secrets.vaultwarden = { + source = ../../private/vaultwarden.age; + dest = "${config.secretsDirectory}/vaultwarden"; + owner = "vaultwarden"; + group = "vaultwarden"; + }; + + networking.firewall.allowedTCPPorts = [ 3012 ]; + + caddyRoutes = [{ + match = [{ host = [ config.vaultwardenServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8222"; }]; + }]; + }]; } diff --git a/private/vaultwarden.age b/private/vaultwarden.age new file mode 100644 index 0000000..523b1bd --- /dev/null +++ b/private/vaultwarden.age @@ -0,0 +1,11 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBqNm0x +YVc0bXp6eldNdkp1QWk2cEI0WFBhVVd3cHhDODNwMS9UUTBPN25JCmxXZnRIcFZr +SFJrQnI3R1BTUk1BcVl3RjlUaXMzSXpqaGdTMi9reno1eHcKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIFlKWCtsWGtWdTI4L0ZFTVRHNFN5by9vTE95MXFoMVZGYlYrM1I2 +alREaE0Kd251SGRDdE96VmZqblhEWXFkZDhvRUZsZ1pnZ3NqdEdJSlBvaXhoOHVB +WQotLS0gaGJNRm14SkdXcTFmYlJUell1WUZUeEllT3ZwMkNaejF3eWJ5U1ZSdno1 +MAqQIT8vvUro+C+avm6lCPfrX9yigKzx/gtKfMB//1Ie7BUo1+o5iYoA+R0luMU8 +/zVX1yGAzDPqas/HfYclIPg3bdjm2dnpz0ltOrOvjA4x3nEzzrmS96zo3Fy1d8oX +oAMw2l/p2QDHI60cyhvC +-----END AGE ENCRYPTED FILE----- From 41d8e30990a013dd004c4ac00ef45032f500358b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 19:06:56 +0000 Subject: [PATCH 061/391] vaultwarden automated backups --- modules/services/backups.nix | 14 ++++++ modules/services/nextcloud.nix | 9 ++-- modules/services/vaultwarden.nix | 73 +++++++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/modules/services/backups.nix b/modules/services/backups.nix index d63e3dd..f07539b 100644 --- a/modules/services/backups.nix +++ b/modules/services/backups.nix @@ -32,6 +32,20 @@ permissions = "0440"; }; + users.users.litestream.extraGroups = [ "backup" ]; + + services.litestream = { + enable = true; + environmentFile = config.secrets.backup.dest; + }; + + # Wait for secret to exist + systemd.services.litestream = { + after = [ "backup-secret.service" ]; + requires = [ "backup-secret.service" ]; + environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + }; + # # Backup library to object storage # services.restic.backups.calibre = { # user = "calibre-web"; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 13f6aeb..55d18eb 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -60,12 +60,11 @@ lib.mkForce "0770"; # Allow litestream and nextcloud to share a sqlite database - users.users.litestream.extraGroups = [ "nextcloud" "backup" ]; + users.users.litestream.extraGroups = [ "nextcloud" ]; users.users.nextcloud.extraGroups = [ "litestream" ]; # Backup sqlite database with litestream services.litestream = { - enable = true; settings = { dbs = [{ path = "${config.services.nextcloud.datadir}/data/nextcloud.db"; @@ -75,14 +74,12 @@ }]; }]; }; - environmentFile = config.secrets.backup.dest; }; # Don't start litestream unless nextcloud is up systemd.services.litestream = { - after = [ "phpfpm-nextcloud.service" "backup-secret.service" ]; - requires = [ "phpfpm-nextcloud.service" "backup-secret.service" ]; - environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + after = [ "phpfpm-nextcloud.service" ]; + requires = [ "phpfpm-nextcloud.service" ]; }; }; diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index 8acb438..e80ab8d 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -1,4 +1,10 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: + +let vaultwardenPath = "/var/lib/bitwarden_rs"; # Default service directory + +in { + + imports = [ ./caddy.nix ./secrets.nix ./backups.nix ]; options = { @@ -49,4 +55,69 @@ }]; }]; + ## Backup config + + # Open to groups, allowing for backups + systemd.services.vaultwarden.serviceConfig.StateDirectoryMode = + lib.mkForce "0770"; + systemd.tmpfiles.rules = [ + "f ${vaultwardenPath}/db.sqlite3 0660 vaultwarden vaultwarden" + "f ${vaultwardenPath}/db.sqlite3-shm 0660 vaultwarden vaultwarden" + "f ${vaultwardenPath}/db.sqlite3-wal 0660 vaultwarden vaultwarden" + ]; + + # Allow litestream and nextcloud to share a sqlite database + users.users.litestream.extraGroups = [ "vaultwarden" ]; + users.users.vaultwarden.extraGroups = [ "litestream" ]; + + # Backup sqlite database with litestream + services.litestream = { + settings = { + dbs = [{ + path = "${vaultwardenPath}/db.sqlite3"; + replicas = [{ + url = + "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/vaultwarden"; + }]; + }]; + }; + }; + + # Don't start litestream unless vaultwarden is up + systemd.services.litestream = { + after = [ "vaultwarden.service" ]; + requires = [ "vaultwarden.service" ]; + }; + + # Run a separate file backup on a schedule + systemd.timers.vaultwarden-backup = { + timerConfig = { + OnCalendar = "*-*-* 06:00:00"; # Once per day + Unit = "vaultwarden-backup.service"; + }; + wantedBy = [ "timers.target" ]; + }; + + # Backup other Vaultwarden data to object storage + systemd.services.vaultwarden-backup = { + description = "Backup Vaultwarden files"; + environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + serviceConfig = { + Type = "oneshot"; + User = "vaultwarden"; + Group = "backup"; + EnvironmentFile = config.secrets.backup.dest; + }; + script = '' + ${pkgs.awscli2}/bin/aws s3 sync \ + ${vaultwardenPath}/ \ + s3://${config.backupS3.bucket}/vaultwarden/ \ + --endpoint-url=https://${config.backupS3.endpoint} \ + --exclude "*db.sqlite3*" \ + --exclude ".db.sqlite3*" + ''; + }; + + }; + } From 27e2a42e460f7724626d9527aa2fd46a3c0cb4d5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 20:21:25 +0000 Subject: [PATCH 062/391] fix: typo in copy --- modules/services/vaultwarden.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index e80ab8d..c8da296 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -66,7 +66,7 @@ in { "f ${vaultwardenPath}/db.sqlite3-wal 0660 vaultwarden vaultwarden" ]; - # Allow litestream and nextcloud to share a sqlite database + # Allow litestream and vaultwarden to share a sqlite database users.users.litestream.extraGroups = [ "vaultwarden" ]; users.users.vaultwarden.extraGroups = [ "litestream" ]; From 982566a92eb9c8f93a9ab441b8c1f9ecf41474f0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 20:34:28 +0000 Subject: [PATCH 063/391] add gitea service --- hosts/oracle/default.nix | 2 + modules/services/gitea.nix | 89 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 modules/services/gitea.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 8f48abf..fe13e85 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -23,6 +23,7 @@ nixpkgs.lib.nixosSystem { transmissionServer = "download.masu.rs"; metricsServer = "metrics.masu.rs"; vaultwardenServer = "vault.masu.rs"; + giteaServer = "git.masu.rs"; # Disable passwords, only use SSH key passwordHash = null; @@ -82,6 +83,7 @@ nixpkgs.lib.nixosSystem { ../../modules/services/transmission.nix ../../modules/services/prometheus.nix ../../modules/services/vaultwarden.nix + ../../modules/services/gitea.nix ../../modules/gaming/minecraft-server.nix ]; } diff --git a/modules/services/gitea.nix b/modules/services/gitea.nix new file mode 100644 index 0000000..e2d01bf --- /dev/null +++ b/modules/services/gitea.nix @@ -0,0 +1,89 @@ +{ config, lib, ... }: + +let giteaPath = "/var/lib/gitea"; # Default service directory + +in { + + imports = [ ./caddy.nix ./backups.nix ]; + + options = { + + giteaServer = lib.mkOption { + description = "Hostname for Gitea."; + type = lib.types.str; + }; + + }; + + config = { + services.gitea = { + enable = true; + httpPort = 3001; + httpAddress = "127.0.0.1"; + rootUrl = "https://${config.giteaServer}/"; + database.type = "sqlite3"; + settings = { + repository = { + DEFAULT_PUSH_CREATE_PRIVATE = true; + DISABLE_HTTP_GIT = false; + ACCESS_CONTROL_ALLOW_ORIGIN = config.giteaServer; + ENABLE_PUSH_CREATE_USER = true; + ENABLE_PUSH_CREATE_ORG = true; + DEFAULT_BRANCH = "main"; + }; + server = { + SSH_PORT = 22; + START_SSH_SERVER = false; # Use sshd instead + DISABLE_SSH = false; + # SSH_LISTEN_HOST = "0.0.0.0"; + # SSH_LISTEN_PORT = 122; + }; + service.DISABLE_REGISTRATION = true; + session.COOKIE_SECURE = true; + ui.SHOW_USER_EMAIL = false; + }; + extraConfig = null; + }; + + networking.firewall.allowedTCPPorts = [ 122 ]; + + caddyRoutes = [{ + match = [{ host = [ config.giteaServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:3001"; }]; + }]; + }]; + + ## Backup config + + # Open to groups, allowing for backups + systemd.services.gitea.serviceConfig.StateDirectoryMode = + lib.mkForce "0770"; + + # Allow litestream and gitea to share a sqlite database + users.users.litestream.extraGroups = [ "gitea" ]; + users.users.gitea.extraGroups = [ "litestream" ]; + + # Backup sqlite database with litestream + services.litestream = { + settings = { + dbs = [{ + path = "${giteaPath}/data/gitea.db"; + replicas = [{ + url = + "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/gitea"; + }]; + }]; + }; + }; + + # Don't start litestream unless gitea is up + systemd.services.litestream = { + after = [ "gitea.service" ]; + requires = [ "gitea.service" ]; + }; + + }; + +} From d97e3fda075cd87d1a6ade2457090ee7870d6edc Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 16 Oct 2022 20:39:04 +0000 Subject: [PATCH 064/391] gitea litestream permissions fixes --- modules/services/gitea.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/services/gitea.nix b/modules/services/gitea.nix index e2d01bf..abdee2d 100644 --- a/modules/services/gitea.nix +++ b/modules/services/gitea.nix @@ -60,6 +60,10 @@ in { # Open to groups, allowing for backups systemd.services.gitea.serviceConfig.StateDirectoryMode = lib.mkForce "0770"; + systemd.tmpfiles.rules = [ + "d ${giteaPath}/data 0775 gitea gitea" + "f ${giteaPath}/data/gitea.db 0660 gitea gitea" + ]; # Allow litestream and gitea to share a sqlite database users.users.litestream.extraGroups = [ "gitea" ]; From ef6c920c48be557745cdbed08ebc8de50b102cca Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 Oct 2022 03:19:23 +0000 Subject: [PATCH 065/391] move calibre-web patch to patches directory still requires overlay because there is no package option --- modules/services/calibre.nix | 3 ++- {modules/services => patches}/calibre-web-cloudflare.patch | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename {modules/services => patches}/calibre-web-cloudflare.patch (100%) diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index dc29b8d..fdb9b61 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -25,7 +25,8 @@ nixpkgs.overlays = [ (final: prev: { calibre-web = prev.calibre-web.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ ./calibre-web-cloudflare.patch ]; + patches = (old.patches or [ ]) + ++ [ ../../patches/calibre-web-cloudflare.patch ]; }); }) ]; diff --git a/modules/services/calibre-web-cloudflare.patch b/patches/calibre-web-cloudflare.patch similarity index 100% rename from modules/services/calibre-web-cloudflare.patch rename to patches/calibre-web-cloudflare.patch From af31c6578880c7a5f3c12318649c01bb24dc36e5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:17:58 +0000 Subject: [PATCH 066/391] fix: generator module references --- generators/aws/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/aws/default.nix b/generators/aws/default.nix index f648c18..6077930 100644 --- a/generators/aws/default.nix +++ b/generators/aws/default.nix @@ -21,9 +21,9 @@ nixos-generators.nixosGenerate { # AWS settings require this permitRootLogin = "prohibit-password"; } - ../hosts/common.nix - ../modules/nixos - ../modules/services/sshd.nix + ../../hosts/common.nix + ../../modules/nixos + ../../modules/services/sshd.nix ] ++ [ # Required to fix diskSize errors during build ({ ... }: { amazonImage.sizeMB = 16 * 1024; }) From 2694e3288cb16aef55428b1898700b814003fc15 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:21:22 +0000 Subject: [PATCH 067/391] move generators to hosts directory --- flake.nix | 16 ++++++++-------- {generators => hosts}/aws/default.nix | 3 +-- {generators => hosts}/aws/main.tf | 0 {generators => hosts}/aws/workflow.yml | 0 4 files changed, 9 insertions(+), 10 deletions(-) rename {generators => hosts}/aws/default.nix (86%) rename {generators => hosts}/aws/main.tf (100%) rename {generators => hosts}/aws/workflow.yml (100%) diff --git a/flake.nix b/flake.nix index 1a9709c..258bc58 100644 --- a/flake.nix +++ b/flake.nix @@ -78,6 +78,14 @@ }; }; + # Package servers into images with a generator + packages.x86_64-linux = with inputs; { + aws = import ./hosts/aws { + inherit nixpkgs nixos-generators home-manager globals; + system = "x86_64-linux"; + }; + }; + apps = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; in rec { @@ -132,14 +140,6 @@ }); - # Package servers into images with a generator - packages.x86_64-linux = with inputs; { - aws = import ./generators/aws { - inherit nixpkgs nixos-generators home-manager globals; - system = "x86_64-linux"; - }; - }; - # Templates for starting other projects quickly templates = rec { default = basic; diff --git a/generators/aws/default.nix b/hosts/aws/default.nix similarity index 86% rename from generators/aws/default.nix rename to hosts/aws/default.nix index 6077930..69bf62c 100644 --- a/generators/aws/default.nix +++ b/hosts/aws/default.nix @@ -14,8 +14,7 @@ nixos-generators.nixosGenerate { networking.hostName = "sheep"; gui.enable = false; colorscheme = (import ../modules/colorscheme/gruvbox); - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; # AWS settings require this diff --git a/generators/aws/main.tf b/hosts/aws/main.tf similarity index 100% rename from generators/aws/main.tf rename to hosts/aws/main.tf diff --git a/generators/aws/workflow.yml b/hosts/aws/workflow.yml similarity index 100% rename from generators/aws/workflow.yml rename to hosts/aws/workflow.yml From 4c685eb8ddbbb972bc6edcb55e9e79bc047a05ab Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:25:06 +0000 Subject: [PATCH 068/391] ignore non-age files in private dir --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1afbbd8..64113bc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ **/.direnv/** result .luarc.json +private/** +!private/**.age From cd204f5ac3fbd61decbefa95941e8a5c7f88b140 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:31:42 +0000 Subject: [PATCH 069/391] move apps declaration to apps directory --- apps/default.nix | 23 +++++++++++++++++++++++ flake.nix | 24 +----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 apps/default.nix diff --git a/apps/default.nix b/apps/default.nix new file mode 100644 index 0000000..f0076ff --- /dev/null +++ b/apps/default.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: rec { + + default = readme; + + # Format and install from nothing + installer = import ./installer.nix { inherit pkgs; }; + + # Display the readme for this repository + readme = import ./readme.nix { inherit pkgs; }; + + # Load the SSH key for this machine + loadkey = import ./loadkey.nix { inherit pkgs; }; + + # Encrypt secret for all machines + encrypt-secret = import ./encrypt-secret.nix { inherit pkgs; }; + + # Re-encrypt secrets for all machines + reencrypt-secrets = import ./reencrypt-secrets.nix { inherit pkgs; }; + + # Connect machine metrics to Netdata Cloud + netdata = import ./netdata-cloud.nix { inherit pkgs; }; + +} diff --git a/flake.nix b/flake.nix index 258bc58..09b8e3c 100644 --- a/flake.nix +++ b/flake.nix @@ -88,29 +88,7 @@ apps = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; - in rec { - default = readme; - - # Format and install from nothing - installer = import ./apps/installer.nix { inherit pkgs; }; - - # Display the readme for this repository - readme = import ./apps/readme.nix { inherit pkgs; }; - - # Load the SSH key for this machine - loadkey = import ./apps/loadkey.nix { inherit pkgs; }; - - # Encrypt secret for all machines - encrypt-secret = import ./apps/encrypt-secret.nix { inherit pkgs; }; - - # Re-encrypt secrets for all machines - reencrypt-secrets = - import ./apps/reencrypt-secrets.nix { inherit pkgs; }; - - # Connect machine metrics to Netdata Cloud - netdata = import ./apps/netdata-cloud.nix { inherit pkgs; }; - - }); + in import ./apps { inherit pkgs; }); devShells = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; From f6096e347234be8d11f330e15d7a0cd0575ad760 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Oct 2022 14:29:50 +0000 Subject: [PATCH 070/391] replace vimwiki with mkdnflow --- modules/mail/himalaya.nix | 3 --- modules/neovim/lua/packer/misc.lua | 32 +++++++++++++++++++++++++++++- modules/neovim/lua/settings.lua | 31 ----------------------------- modules/repositories/notes.nix | 2 +- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index bca7cbf..90dc298 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -1,8 +1,5 @@ { config, pkgs, lib, ... }: { - # Required to place identity file on machine - imports = [ ../shell/age.nix ]; - options = { mailUser = lib.mkOption { type = lib.types.str; diff --git a/modules/neovim/lua/packer/misc.lua b/modules/neovim/lua/packer/misc.lua index 5b015a4..014f839 100644 --- a/modules/neovim/lua/packer/misc.lua +++ b/modules/neovim/lua/packer/misc.lua @@ -29,7 +29,37 @@ M.packer = function(use) }) -- Markdown renderer / wiki notes - use("vimwiki/vimwiki") + -- use("vimwiki/vimwiki") + use({ + "jakewvincent/mkdnflow.nvim", + config = function() + require("mkdnflow").setup({ + modules = { + bib = false, + conceal = true, + folds = false, + }, + perspective = { + priority = "current", + fallback = "first", + nvim_wd_heel = false, -- Don't change working dir + }, + links = { + style = "markdown", + conceal = true, + }, + wrap = true, + to_do = { + symbols = { " ", "-", "x" }, + }, + }) + -- Save when moving to new buffer + vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + command = "set autowriteall", + }) + end, + }) end return M diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index 913be33..130d8e2 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -83,34 +83,3 @@ vim.g.netrw_banner = 0 -- Remove useless banner vim.g.netrw_winsize = 15 -- Explore window takes % of page vim.g.netrw_browse_split = 4 -- Open in previous window vim.g.netrw_altv = 1 -- Always split left - --- VimWiki -vim.g.vimwiki_list = { - { - ["path"] = "$NOTES_PATH", - ["syntax"] = "markdown", - ["index"] = "home", - ["ext"] = ".md", - }, -} -vim.g.vimwiki_key_mappings = { - ["all_maps"] = 1, - ["mouse"] = 1, -} -vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open -vim.g.vimwiki_create_link = 0 -- Don't automatically create new links -vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression -vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion -vim.api.nvim_exec( - [[ - au FileType markdown inoremap ;tt :AddTag - - function! PInsert(item) - let @z=a:item - norm "zpx - endfunction - - command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) -]], - false -) diff --git a/modules/repositories/notes.nix b/modules/repositories/notes.nix index c357723..47e521b 100644 --- a/modules/repositories/notes.nix +++ b/modules/repositories/notes.nix @@ -3,7 +3,7 @@ home-manager.users.${config.user} = { home.sessionVariables = { - NOTES_PATH = "${config.homePath}/dev/personal/notes"; + NOTES_PATH = "${config.homePath}/dev/personal/notes/content"; }; }; From 941fa359d9ccdaff5482e833878e7f5c1551c22b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Oct 2022 15:10:30 +0000 Subject: [PATCH 071/391] add windows app plaintext list --- windows/windows-programs.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 windows/windows-programs.md diff --git a/windows/windows-programs.md b/windows/windows-programs.md new file mode 100644 index 0000000..088575e --- /dev/null +++ b/windows/windows-programs.md @@ -0,0 +1,20 @@ +# Windows Programs + +- Monitorian (monitor brightness) +- Firefox +- Alacritty +- Mullvad +- Keybase (dokan) +- qBittorrent +- 1Password +- Authy Desktop +- Autohotkey +- 7zip +- Audacity +- Calibre +- Discord +- Git +- Netflix +- Obsidian +- Realtek HD Audio +- AMD Software From be581dba1f37033963ad3d75654f7330b6c63606 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 Oct 2022 04:16:42 +0000 Subject: [PATCH 072/391] fix: jellyfin dir permissions for nextcloud --- modules/services/jellyfin.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index b09d36b..eaf62bc 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -20,8 +20,10 @@ }]; # Create videos directory, allow anyone in Jellyfin group to manage it - systemd.tmpfiles.rules = - [ "d /var/lib/jellyfin/library 0775 jellyfin jellyfin" ]; + systemd.tmpfiles.rules = [ + "d /var/lib/jellyfin 0775 jellyfin jellyfin" + "d /var/lib/jellyfin/library 0775 jellyfin jellyfin" + ]; }; From 3dcafb8c25373edc78406e98b7737ca22ac6ffb9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:22:17 -0400 Subject: [PATCH 073/391] package ocr script with dependencies --- modules/darwin/utilities.nix | 25 +++++++++++++++++++++---- modules/shell/bash/scripts/ocr.sh | 9 ++++----- modules/shell/utilities.nix | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index d73a6c3..30b509b 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -1,4 +1,19 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, lib, ... }: + +let + + # Quickly package shell scripts with their dependencies + # From https://discourse.nixos.org/t/how-to-create-a-script-with-dependencies/7970/6 + mkScript = { name, file, env ? [ ] }: + pkgs.writeScriptBin name '' + for i in ${lib.concatStringsSep " " env}; do + export PATH="$i/bin:$PATH" + done + + exec ${pkgs.bash}/bin/bash ${file} $@ + ''; + +in { home-manager.users.${config.user} = { @@ -17,9 +32,11 @@ consul noti # Create notifications programmatically ipcalc # Make IP network calculations - whois # Lookup IPs - (pkgs.writeScriptBin "ocr" - (builtins.readFile ../shell/bash/scripts/ocr.sh)) + (mkScript { + name = "ocr"; + file = ../shell/bash/scripts/ocr.sh; + env = [ tesseract ]; + }) ]; programs.fish.shellAbbrs = { diff --git a/modules/shell/bash/scripts/ocr.sh b/modules/shell/bash/scripts/ocr.sh index 1a6b0c7..313a069 100755 --- a/modules/shell/bash/scripts/ocr.sh +++ b/modules/shell/bash/scripts/ocr.sh @@ -1,5 +1,4 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p tesseract +#!/usr/bin/env bash # Yoinked from https://github.com/JJGO/dotfiles # Adapted from https://github.com/sdushantha/bin @@ -9,13 +8,13 @@ TEXT_FILE="/tmp/ocr.txt" IMAGE_FILE="/tmp/ocr.png" function notify-send() { - osascript -e "display notification \"$2\" with title \"OCR\"" + /usr/bin/osascript -e "display notification \"$2\" with title \"OCR\"" } PATH="/usr/local/bin/:$PATH" # Take screenshot by selecting the area -screencapture -i "$IMAGE_FILE" +/usr/sbin/screencapture -i "$IMAGE_FILE" # Get the exit code of the previous command. # So in this case, it is the screenshot command. If it did not exit with an @@ -44,7 +43,7 @@ fi # Copy text to clipboard # xclip -selection clip < "$TEXT_FILE" -pbcopy <"$TEXT_FILE" +/usr/bin/pbcopy <"$TEXT_FILE" # Send a notification with the text that was grabbed using OCR notify-send "ocr" "$(cat $TEXT_FILE)" diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index d5d09e2..33d9c49 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -31,7 +31,7 @@ in { vimv-rs # Batch rename files dig # DNS lookup lf # File viewer - whois # Lookup IPs + # whois # Lookup IPs age # Encryption ]; From bf09e166a9f668080b8e651e5b339072ebd7f1d9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 28 Oct 2022 23:58:25 -0400 Subject: [PATCH 074/391] fix: grub wrong monitor --- modules/hardware/boot.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/hardware/boot.nix b/modules/hardware/boot.nix index 7d5a852..d92941f 100644 --- a/modules/hardware/boot.nix +++ b/modules/hardware/boot.nix @@ -10,6 +10,9 @@ # Check for other OSes and make them available useOSProber = true; + # Attempt to display GRUB on widescreen monitor + gfxmodeEfi = "1920x1080"; + # Install GRUB onto the boot disk # device = config.fileSystems."/boot".device; From e16674c81787227f1658fc24a14dea1a4cd8c960 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 28 Oct 2022 23:58:33 -0400 Subject: [PATCH 075/391] tweaks for i3 and common --- hosts/common.nix | 2 +- hosts/desktop/default.nix | 1 - modules/graphical/i3.nix | 22 ++++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/hosts/common.nix b/hosts/common.nix index 2beb87b..5143bce 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -23,7 +23,7 @@ }; identityFile = lib.mkOption { type = lib.types.str; - description = "Path to existing identity file."; + description = "Path to existing private key file."; default = "/etc/ssh/ssh_host_ed25519_key"; }; gui = { diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index ace5cad..2244179 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -14,7 +14,6 @@ nixpkgs.lib.nixosSystem { nix.registry.nixpkgs.flake = nixpkgs; identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gaming.steam = true; - gaming.leagueoflegends = true; gaming.legendary = true; gui = { enable = true; diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index 6c01f65..ff9891d 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -9,11 +9,11 @@ let in { - config = lib.mkIf config.services.xserver.enable { + config = { services.xserver.windowManager = { i3 = { - enable = true; + enable = config.services.xserver.enable; package = pkgs.i3-gaps; }; }; @@ -25,7 +25,7 @@ in { home-manager.users.${config.user} = { xsession.windowManager.i3 = { - enable = true; + enable = config.services.xserver.enable; package = pkgs.i3-gaps; config = let modifier = "Mod4"; # Super key @@ -238,7 +238,7 @@ in { }; programs.fish.functions = { - update-lock-screen = { + update-lock-screen = lib.mkIf config.services.xserver.enable { description = "Update lockscreen with wallpaper"; body = lockUpdate; }; @@ -247,17 +247,19 @@ in { # Update lock screen cache only if cache is empty home.activation.updateLockScreenCache = let cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; - in config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then - $DRY_RUN_CMD ${lockUpdate} - fi - ''; + in lib.mkIf config.services.xserver.enable + (config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' + if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then + $DRY_RUN_CMD ${lockUpdate} + fi + ''); }; # Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service systemd.services.lock = { + enable = config.services.xserver.enable; description = "Lock the screen on resume from suspend"; before = [ "sleep.target" "suspend.target" ]; serviceConfig = { From b718a01dc4ba4211d96a4c13481bd8317b0b9d4f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 29 Oct 2022 08:57:14 -0400 Subject: [PATCH 076/391] i think i fixed picom screen tearing --- modules/graphical/picom.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/graphical/picom.nix b/modules/graphical/picom.nix index 6c555b4..c9ad371 100644 --- a/modules/graphical/picom.nix +++ b/modules/graphical/picom.nix @@ -6,6 +6,7 @@ services.picom = { enable = true; + backend = "glx"; settings = { blur = false; blurExclude = [ ]; From 2af30faf7c87cc797dff05017860e469b2883090 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 29 Oct 2022 14:42:37 -0400 Subject: [PATCH 077/391] update system and fix nvim --- flake.lock | 36 ++++++++++++++-------------- modules/gaming/steam.nix | 2 +- modules/neovim/lua/packer/lsp.lua | 4 ++-- modules/neovim/lua/packer/syntax.lua | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/flake.lock b/flake.lock index a560b71..5a442fc 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1664210064, - "narHash": "sha256-df6nKVZe/yAhmJ9csirTPahc0dldwm3HBhCVNA6qWr0=", + "lastModified": 1666776005, + "narHash": "sha256-HwSMF19PpczfqNHKcFsA6cF4PVbG00uUSdbq6q3jB5o=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "02d2551c927b7d65ded1b3c7cd13da5cc7ae3fcf", + "rev": "f6648ca0698d1611d7eadfa72b122252b833f86c", "type": "github" }, "original": { @@ -60,11 +60,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1664273942, - "narHash": "sha256-PFQR1UJQs7a7eaH5YoCZky5dmxR5cjaKRK+MpPbR7YE=", + "lastModified": 1666903647, + "narHash": "sha256-sFI1Gh9DTGzHnBINondupUGYbe+T0wZcpcZjkW0qffM=", "owner": "nix-community", "repo": "home-manager", - "rev": "1f5ef2bb419a327fae28a83b50fab50959132c24", + "rev": "213a06295dff96668a1d673b9fd1c03ce1de6745", "type": "github" }, "original": { @@ -97,11 +97,11 @@ ] }, "locked": { - "lastModified": 1660727616, - "narHash": "sha256-zYTIvdPMYMx/EYqXODAwIIU30RiEHqNHdgarIHuEYZc=", + "lastModified": 1666812839, + "narHash": "sha256-0nBDgjPU+iDsvz89W+cDEyhnFGSwCJmwDl/gMGqYiU0=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "adccd191a0e83039d537e021f19495b7bad546a1", + "rev": "41f3518bc194389df22a3d198215eae75e6b5ab9", "type": "github" }, "original": { @@ -112,11 +112,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1664195620, - "narHash": "sha256-/0V1a1gAR+QbiQe4aCxBoivhkxss0xyt2mBD6yDrgjw=", + "lastModified": 1666959691, + "narHash": "sha256-TRpWA3t8ata79HOGtFd5dDCl1kJQmIE16PDF53/Hcxo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "62228ccc672ed000f35b1e5c82e4183e46767e52", + "rev": "448a599c49978c2794401bfc3a2e1fba1a8663be", "type": "github" }, "original": { @@ -143,11 +143,11 @@ }, "nur": { "locked": { - "lastModified": 1664282944, - "narHash": "sha256-PrID+Tc90HWhkbO4b2kk3MFgjK+iBDWtDd534Y2D2Zs=", + "lastModified": 1667025500, + "narHash": "sha256-88akaieCIrqta3Uyha7Zv3FJWzKJebb2BrOdZba1zdI=", "owner": "nix-community", "repo": "nur", - "rev": "dcc2af3d2504af6726c5cf40eb5e1165d5700721", + "rev": "21dd192519af12a01f1348bbfa86cde47f7aa392", "type": "github" }, "original": { @@ -205,11 +205,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1661772734, - "narHash": "sha256-DkvAaLDg9D6O0i2MzUknaf/U078K4KWAZaJQmNC/tL8=", + "lastModified": 1666720338, + "narHash": "sha256-7V91ZtTz7zDXb6hivktQ9RlBglP+WEkYFSciPJHwMJw=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "c1b0259313f661cf74051c916cf3bb4f061ce11f", + "rev": "7bfb8f5aa91fee30a189eae32cda8ddc465076df", "type": "github" }, "original": { diff --git a/modules/gaming/steam.nix b/modules/gaming/steam.nix index b23bd7c..6e1996b 100644 --- a/modules/gaming/steam.nix +++ b/modules/gaming/steam.nix @@ -4,7 +4,7 @@ config = lib.mkIf config.gaming.steam { hardware.steam-hardware.enable = true; - unfreePackages = [ "steam" "steam-original" "steamcmd" ]; + unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ]; environment.systemPackages = with pkgs; [ steam diff --git a/modules/neovim/lua/packer/lsp.lua b/modules/neovim/lua/packer/lsp.lua index 9316d49..74ae245 100644 --- a/modules/neovim/lua/packer/lsp.lua +++ b/modules/neovim/lua/packer/lsp.lua @@ -133,14 +133,14 @@ M.packer = function(use) }, -- Format on save on_attach = function(client) - if client.resolved_capabilities.document_formatting then + if client.server_capabilities.document_formatting then local id = vim.api.nvim_create_augroup("LspFormatting", { clear = true, }) vim.api.nvim_create_autocmd("BufWritePre", { group = id, pattern = "*", - callback = vim.lsp.buf.formatting_seq_sync, + callback = vim.lsp.buf.format, }) end end, diff --git a/modules/neovim/lua/packer/syntax.lua b/modules/neovim/lua/packer/syntax.lua index 4ee4ade..434c137 100644 --- a/modules/neovim/lua/packer/syntax.lua +++ b/modules/neovim/lua/packer/syntax.lua @@ -8,7 +8,7 @@ M.packer = function(use) -- Syntax engine use({ "nvim-treesitter/nvim-treesitter", - commit = "989c75046c46d2ed96bb65c5badd6b8f785e7f09", + commit = "9ada5f70f98d51e9e3e76018e783b39fd1cd28f7", run = ":TSUpdate", config = function() require("nvim-treesitter.configs").setup({ From dfd903d3c94e96aeab98e6d3e1612c6e47838be5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 13:57:14 -0400 Subject: [PATCH 078/391] add aerc and fix nvim 0.8 --- hosts/desktop/default.nix | 2 +- modules/mail/aerc.nix | 186 ++++++++++++++++++++++++++++ modules/mail/default.nix | 83 +++++++++++++ modules/mail/himalaya.nix | 84 ++----------- modules/neovim/lua/packer/lsp.lua | 17 +-- modules/neovim/lua/packer/misc.lua | 6 +- modules/neovim/lua/packer/speed.lua | 43 ------- modules/neovim/lua/settings.lua | 9 +- 8 files changed, 297 insertions(+), 133 deletions(-) create mode 100644 modules/mail/aerc.nix create mode 100644 modules/mail/default.nix diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 2244179..bc771e4 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -33,7 +33,7 @@ nixpkgs.lib.nixosSystem { ../../modules/graphical ../../modules/gaming ../../modules/applications - ../../modules/mail/himalaya.nix + ../../modules/mail/default.nix ../../modules/repositories/notes.nix ../../modules/services/keybase.nix ../../modules/services/gnupg.nix diff --git a/modules/mail/aerc.nix b/modules/mail/aerc.nix new file mode 100644 index 0000000..348fe75 --- /dev/null +++ b/modules/mail/aerc.nix @@ -0,0 +1,186 @@ +{ config, pkgs, ... }: { + + config = { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + w3m # Render HTML + dante # Socksify for rendering HTML + ]; + + programs.aerc = { + enable = true; + extraBinds = { + # Binds are of the form = + # To use '=' in a key sequence, substitute it with "Eq": "" + # If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit + global = { + "" = ":prev-tab"; + "" = ":next-tab "; + "" = ":term"; + "?" = ":help keys"; + }; + + messages = { + q = ":quit"; + + j = ":next "; + "" = ":next"; + "" = ":next 50%"; + "" = ":next 100%"; + "" = ":next 100%"; + + k = ":prev "; + "" = ":prev"; + "" = ":prev 50%"; + "" = ":prev 100%"; + "" = ":prev 100%"; + g = ":select 0 "; + G = ":select -1"; + + J = ":next-folder "; + K = ":prev-folder"; + H = ":collapse-folder"; + L = ":expand-folder"; + + v = ":mark -t"; + V = ":mark -v"; + + T = ":toggle-threads"; + + "" = ":view"; + d = ":prompt 'Really delete this message?' 'delete-message'"; + D = ":delete"; + A = ":archive flat"; + + C = ":compose"; + + rr = ":reply -a"; + rq = ":reply -aq"; + Rr = ":reply"; + Rq = ":reply -q"; + + c = ":cf"; + "$" = ":term"; + "!" = ":term"; + "|" = ":pipe"; + + "/" = ":search"; + "\\" = ":filter "; + n = ":next-result"; + N = ":prev-result"; + "" = ":clear"; + }; + + "messages:folder=Drafts" = { "" = ":recall"; }; + + view = { + "/" = ":toggle-key-passthrough /"; + q = ":close"; + O = ":open"; + S = ":save"; + "|" = ":pipe"; + D = ":delete"; + A = ":archive flat"; + + "" = ":open-link "; + + f = ":forward "; + rr = ":reply -a"; + rq = ":reply -aq"; + Rr = ":reply"; + Rq = ":reply -q"; + + H = ":toggle-headers"; + "" = ":prev-part"; + "" = ":next-part"; + J = ":next "; + K = ":prev"; + }; + + "view::passthrough" = { + "$noinherit" = "true"; + "$ex" = ""; + "" = ":toggle-key-passthrough"; + }; + + compose = { + # Keybindings used when the embedded terminal is not selected in the compose + # view + "$noinherit" = "true"; + "$ex" = ""; + "" = ":prev-field"; + "" = ":next-field"; + "" = ":switch-account -p"; + "" = ":switch-account -n"; + "" = ":next-field"; + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::editor" = { + # Keybindings used when the embedded terminal is selected in the compose view + "$noinherit" = "true"; + "$ex" = ""; + "" = ":prev-field"; + "" = ":next-field"; + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + "compose::review" = { + # Keybindings used when reviewing a message to be sent + y = ":send "; + n = ":abort"; + p = ":postpone"; + q = ":choose -o d discard abort -o p postpone postpone"; + e = ":edit"; + a = ":attach"; + d = ":detach"; + }; + + terminal = { + "$noinherit" = "true"; + "$ex" = ""; + "" = ":prev-tab"; + "" = ":next-tab"; + }; + + }; + extraConfig = { + general.unsafe-accounts-conf = true; + viewer = { pager = "${pkgs.less}/bin/less -R"; }; + filters = { + "text/plain" = + "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; + "text/calendar" = + "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/calendar"; + "text/html" = + "${pkgs.aerc}/share/aerc/filters/html"; # Requires w3m, dante + # "text/html" = + # "${pkgs.aerc}/share/aerc/filters/html | ${pkgs.aerc}/share/aerc/filters/colorize"; + # "text/*" = + # ''${pkgs.bat}/bin/bat -fP --file-name="$AERC_FILENAME "''; + "message/delivery-status" = + "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; + "message/rfc822" = + "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; + "application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh"; + }; + }; + }; + accounts.email.accounts.home.aerc = { + enable = true; + extraAccounts = { + check-mail = "1m"; + check-mail-cmd = "${pkgs.isync}/bin/mbsync -a"; + }; + }; + + programs.fish.shellAbbrs = { ae = "aerc"; }; + + }; + + }; +} diff --git a/modules/mail/default.nix b/modules/mail/default.nix new file mode 100644 index 0000000..61a7117 --- /dev/null +++ b/modules/mail/default.nix @@ -0,0 +1,83 @@ +{ config, pkgs, lib, ... }: { + + imports = [ ./himalaya.nix ./aerc.nix ]; + + options = { + mailUser = lib.mkOption { + type = lib.types.str; + description = "User name for the email address."; + default = config.user; + }; + mailServer = lib.mkOption { + type = lib.types.str; + description = "Server name for the email address."; + }; + }; + + config = { + + home-manager.users.${config.user} = { + programs.mbsync = { enable = true; }; + services.mbsync = lib.mkIf pkgs.stdenv.isLinux { + enable = true; + frequency = "*:0/5"; + }; + accounts.email = { + maildirBasePath = "${config.homePath}/mail"; + accounts = { + home = let address = "${config.mailUser}@${config.mailServer}"; + in { + userName = address; + realName = config.fullName; + primary = true; + inherit address; + aliases = map (mailUser: "${mailUser}@${config.mailServer}") [ + "me" + "hey" + "admin" + ]; + alot = { }; + flavor = "plain"; + folders = { }; + getmail = { }; + imap = { + host = "imap.purelymail.com"; + port = 993; + tls.enable = true; + }; + imapnotify = { + enable = false; + boxes = [ ]; + onNotify = ""; + onNotifyPost = ""; + }; + maildir = { path = "main"; }; + mbsync = { + enable = true; + create = "maildir"; + expunge = "none"; + remove = "none"; + patterns = [ "*" ]; + extraConfig.channel = { + CopyArrivalDate = "yes"; # Sync time of original message + }; + }; + mu.enable = false; + notmuch.enable = false; + passwordCommand = + "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ + builtins.toString ../../private/mailpass.age + }"; + smtp = { + host = "smtp.purelymail.com"; + port = 465; + tls.enable = true; + }; + }; + }; + }; + + }; + + }; +} diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 90dc298..12748d3 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -1,87 +1,17 @@ -{ config, pkgs, lib, ... }: { - - options = { - mailUser = lib.mkOption { - type = lib.types.str; - description = "User name for the email address."; - default = config.user; - }; - mailServer = lib.mkOption { - type = lib.types.str; - description = "Server name for the email address."; - }; - }; +{ config, ... }: { config = { home-manager.users.${config.user} = { programs.himalaya = { enable = true; }; - programs.mbsync = { enable = true; }; - services.mbsync = lib.mkIf pkgs.stdenv.isLinux { + accounts.email.accounts.home.himalaya = { enable = true; - frequency = "*:0/5"; - }; - - accounts.email = { - maildirBasePath = "${config.homePath}/mail"; - accounts = { - home = let address = "${config.mailUser}@${config.mailServer}"; - in { - userName = address; - realName = config.fullName; - primary = true; - inherit address; - aliases = map (mailUser: "${mailUser}@${config.mailServer}") [ - "me" - "hey" - "admin" - ]; - alot = { }; - flavor = "plain"; - folders = { }; - getmail = { }; - himalaya = { - enable = true; - settings = { - downloads-dir = config.userDirs.download; - smtp-insecure = true; - }; - }; - imap = { - host = "imap.purelymail.com"; - port = 993; - tls.enable = true; - }; - imapnotify = { - enable = false; - boxes = [ ]; - onNotify = ""; - onNotifyPost = ""; - }; - maildir = { path = "main"; }; - mbsync = { - enable = true; - create = "maildir"; - expunge = "none"; - remove = "none"; - patterns = [ "*" ]; - extraConfig.channel = { - CopyArrivalDate = "yes"; # Sync time of original message - }; - }; - mu.enable = false; - notmuch.enable = false; - passwordCommand = - "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ - builtins.toString ../../private/mailpass.age - }"; - smtp = { - host = "smtp.purelymail.com"; - port = 465; - tls.enable = true; - }; - }; + settings = { + backend = "imap"; + sender = "smtp"; + downloads-dir = config.userDirs.download; + smtp-insecure = true; }; }; diff --git a/modules/neovim/lua/packer/lsp.lua b/modules/neovim/lua/packer/lsp.lua index 74ae245..1a4ccc2 100644 --- a/modules/neovim/lua/packer/lsp.lua +++ b/modules/neovim/lua/packer/lsp.lua @@ -79,6 +79,7 @@ M.packer = function(use) return vim.fn.executable(program) == 1 end + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) require("null-ls").setup({ sources = { require("null-ls").builtins.formatting.stylua.with({ @@ -132,15 +133,15 @@ M.packer = function(use) -- require("null-ls").builtins.diagnostics.pylint, }, -- Format on save - on_attach = function(client) - if client.server_capabilities.document_formatting then - local id = vim.api.nvim_create_augroup("LspFormatting", { - clear = true, - }) + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePre", { - group = id, - pattern = "*", - callback = vim.lsp.buf.format, + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, }) end end, diff --git a/modules/neovim/lua/packer/misc.lua b/modules/neovim/lua/packer/misc.lua index 014f839..017fef1 100644 --- a/modules/neovim/lua/packer/misc.lua +++ b/modules/neovim/lua/packer/misc.lua @@ -53,10 +53,12 @@ M.packer = function(use) symbols = { " ", "-", "x" }, }, }) - -- Save when moving to new buffer vim.api.nvim_create_autocmd("FileType", { pattern = "markdown", - command = "set autowriteall", + callback = function() + vim.o.autowriteall = true -- Save in new buffer + vim.o.wrapmargin = 79 -- Wrap text automatically + end, }) end, }) diff --git a/modules/neovim/lua/packer/speed.lua b/modules/neovim/lua/packer/speed.lua index 414715e..57222e2 100644 --- a/modules/neovim/lua/packer/speed.lua +++ b/modules/neovim/lua/packer/speed.lua @@ -8,49 +8,6 @@ M.packer = function(use) require("impatient") end, }) - - -- Improve speed and filetype detection - use({ - "nathom/filetype.nvim", - config = function() - -- Filetype for .env files - local envfiletype = function() - vim.bo.filetype = "text" - vim.bo.syntax = "sh" - end - -- Force filetype patterns that Vim doesn't know about - require("filetype").setup({ - overrides = { - extensions = { - Brewfile = "brewfile", - muttrc = "muttrc", - tfvars = "terraform", - tf = "terraform", - }, - literal = { - Caskfile = "brewfile", - [".gitignore"] = "gitignore", - config = "config", - }, - complex = { - [".*git/config"] = "gitconfig", - ["tmux.conf%..*link"] = "tmux", - ["gitconfig%..*link"] = "gitconfig", - [".*ignore%..*link"] = "gitignore", - [".*%.toml%..*link"] = "toml", - }, - function_extensions = {}, - function_literal = { - [".envrc"] = envfiletype, - [".env"] = envfiletype, - [".env.dev"] = envfiletype, - [".env.prod"] = envfiletype, - [".env.example"] = envfiletype, - }, - }, - }) - end, - }) end return M diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index 130d8e2..ef2cec6 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -32,8 +32,6 @@ vim.opt.completeopt = { "menuone", "noselect", } --- Required until 0.6.0: do not source the default filetype.vim -vim.g.did_load_filetypes = 1 -- Remember last position when reopening file vim.api.nvim_exec( @@ -77,6 +75,13 @@ vim.api.nvim_exec( false ) +vim.api.nvim_create_autocmd("FileType", { + pattern = "*.eml", + callback = function() + vim.o.wrapmargin = 79 -- Wrap text automatically + end, +}) + -- Netrw vim.g.netrw_liststyle = 3 -- Change style to 'tree' view vim.g.netrw_banner = 0 -- Remove useless banner From b15cd8c0b653c95ce42097105c91a6c33e400456 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:13:32 -0400 Subject: [PATCH 079/391] add basic kitty config closes #7 --- modules/applications/kitty.nix | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 modules/applications/kitty.nix diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix new file mode 100644 index 0000000..c41201a --- /dev/null +++ b/modules/applications/kitty.nix @@ -0,0 +1,73 @@ +{ config, pkgs, lib, ... }: { + + config = lib.mkIf config.gui.enable { + home-manager.users.${config.user} = { + # xsession.windowManager.i3.config.terminal = "kitty"; + # programs.rofi.terminal = "${pkgs.kitty}/bin/kitty"; + programs.kitty = { + enable = true; + darwinLaunchOptions = null; + environment = { }; + extraConfig = ""; + font.size = 14; + keybindings = { }; + settings = { + + # Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache) + background = config.colorscheme.base00; + foreground = config.colorscheme.base05; + selection_background = config.colorscheme.base05; + selection_foreground = config.colorscheme.base00; + url_color = config.colorscheme.base04; + cursor = config.colorscheme.base05; + active_border_color = config.colorscheme.base03; + inactive_border_color = config.colorscheme.base01; + active_tab_background = config.colorscheme.base00; + active_tab_foreground = config.colorscheme.base05; + inactive_tab_background = config.colorscheme.base01; + inactive_tab_foreground = config.colorscheme.base04; + tab_bar_background = config.colorscheme.base01; + + # normal + color0 = config.colorscheme.base00; + color1 = config.colorscheme.base08; + color2 = config.colorscheme.base0B; + color3 = config.colorscheme.base0A; + color4 = config.colorscheme.base0D; + color5 = config.colorscheme.base0E; + color6 = config.colorscheme.base0C; + color7 = config.colorscheme.base05; + + # bright + color8 = config.colorscheme.base03; + color9 = config.colorscheme.base08; + color10 = config.colorscheme.base0B; + color11 = config.colorscheme.base0A; + color12 = config.colorscheme.base0D; + color13 = config.colorscheme.base0E; + color14 = config.colorscheme.base0C; + color15 = config.colorscheme.base07; + + # extended base16 colors + color16 = config.colorscheme.base09; + color17 = config.colorscheme.base0F; + color18 = config.colorscheme.base01; + color19 = config.colorscheme.base02; + color20 = config.colorscheme.base04; + color21 = config.colorscheme.base06; + + # Scrollback + scrolling_lines = 10000; + scrollback_pager_history_size = 10; # MB + scrollback_pager = '' + ${pkgs.neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; + + # Window + window_padding_width = 4; + + # macos_traditional_fullscreen = true; + }; + }; + }; + }; +} From 2d10939285f4c9ffb3858d42896592c0c14b3fb9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:14:41 -0400 Subject: [PATCH 080/391] clean up flake inputs and allow standalone home-manager closes #11 --- flake.nix | 30 +++++++++++++++++------------- hosts/aws/default.nix | 4 +++- hosts/desktop/default.nix | 4 +++- hosts/macbook/default.nix | 4 +++- hosts/oracle/default.nix | 4 +++- hosts/wsl/default.nix | 4 +++- modules/darwin/nixpkgs.nix | 7 +++++++ modules/shell/nixpkgs.nix | 8 ++++++++ 8 files changed, 47 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 09b8e3c..d588a57 100644 --- a/flake.nix +++ b/flake.nix @@ -61,27 +61,31 @@ # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - in { + in rec { - nixosConfigurations = with inputs; { - desktop = import ./hosts/desktop { - inherit nixpkgs home-manager nur globals wallpapers; - }; - wsl = import ./hosts/wsl { inherit nixpkgs wsl home-manager globals; }; - oracle = - import ./hosts/oracle { inherit nixpkgs home-manager globals; }; + nixosConfigurations = { + desktop = import ./hosts/desktop { inherit inputs globals; }; + wsl = import ./hosts/wsl { inherit inputs globals; }; + oracle = import ./hosts/oracle { inherit inputs globals; }; }; - darwinConfigurations = with inputs; { - macbook = import ./hosts/macbook { - inherit nixpkgs darwin home-manager nur globals; - }; + darwinConfigurations = { + macbook = import ./hosts/macbook { inherit inputs globals; }; + }; + + # For quickly applying local settings with: + # home-manager switch --flake .#desktop + homeConfigurations = { + desktop = + nixosConfigurations.desktop.config.home-manager.users.${globals.user}.home; + macbook = + darwinConfigurations.macbook.config.home-manager.users."Noah.Masur".home; }; # Package servers into images with a generator packages.x86_64-linux = with inputs; { aws = import ./hosts/aws { - inherit nixpkgs nixos-generators home-manager globals; + inherit inputs globals; system = "x86_64-linux"; }; }; diff --git a/hosts/aws/default.nix b/hosts/aws/default.nix index 69bf62c..036679f 100644 --- a/hosts/aws/default.nix +++ b/hosts/aws/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, system, nixos-generators, home-manager, globals, ... }: +{ inputs, globals, ... }: + +with inputs; nixos-generators.nixosGenerate { inherit system; diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index bc771e4..198e910 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, home-manager, nur, globals, wallpapers, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for my desktop nixpkgs.lib.nixosSystem { diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 8d3dcf4..828c732 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, darwin, home-manager, nur, globals, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for my work MacBook darwin.lib.darwinSystem { diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index fe13e85..25fa460 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, home-manager, globals, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for an Oracle free server diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index 95cc9f3..2c700b4 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -1,4 +1,6 @@ -{ nixpkgs, wsl, home-manager, globals, ... }: +{ inputs, globals, ... }: + +with inputs; # System configuration for WSL nixpkgs.lib.nixosSystem { diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index 3f8fbc1..b3e69ce 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -18,6 +18,13 @@ commandline --function execute ''; }; + rebuild-home = lib.mkForce { + body = '' + git -C ${config.dotfilesPath} add --intent-to-add --all + commandline -r ${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline --function execute + ''; + }; }; }; diff --git a/modules/shell/nixpkgs.nix b/modules/shell/nixpkgs.nix index bb2096f..e6a1840 100644 --- a/modules/shell/nixpkgs.nix +++ b/modules/shell/nixpkgs.nix @@ -12,6 +12,7 @@ nixh = "man home-configuration.nix"; nr = "rebuild-nixos"; nro = "rebuild-nixos offline"; + hm = "rebuild-home"; }; functions = { nix-shell-run = { @@ -43,6 +44,13 @@ commandline --function execute ''; }; + rebuild-home = { + body = '' + git -C ${config.dotfilesPath} add --intent-to-add --all + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline --function execute + ''; + }; }; }; From c74d003a57fe2b9f7ede34e3abcebb67b47be076 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:15:32 -0400 Subject: [PATCH 081/391] change alacritty scrollback keybind to match kitty add fonts for kitty --- modules/applications/alacritty.nix | 4 ++-- modules/applications/default.nix | 1 + modules/darwin/fonts.nix | 5 +++++ modules/graphical/fonts.nix | 1 + windows/alacritty.yml | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index 8f95551..2c93b60 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -34,8 +34,8 @@ chars = "\\x11F"; } { - key = "K"; - mods = "Control"; + key = "H"; + mods = "Control|Shift"; mode = "~Vi"; action = "ToggleViMode"; } diff --git a/modules/applications/default.nix b/modules/applications/default.nix index 6d0ca0a..ee01e55 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -6,6 +6,7 @@ ./calibre.nix ./discord.nix ./firefox.nix + ./kitty.nix ./media.nix ./obsidian.nix ./qbittorrent.nix diff --git a/modules/darwin/fonts.nix b/modules/darwin/fonts.nix index 20ea0dc..874457a 100644 --- a/modules/darwin/fonts.nix +++ b/modules/darwin/fonts.nix @@ -9,6 +9,11 @@ font.normal.family = "FiraCode Nerd Font Mono"; }; + programs.kitty.font = { + package = pkgs.nerdfonts; + name = "FiraCode"; + }; + }; } diff --git a/modules/graphical/fonts.nix b/modules/graphical/fonts.nix index ae81955..55d6245 100644 --- a/modules/graphical/fonts.nix +++ b/modules/graphical/fonts.nix @@ -21,6 +21,7 @@ in { services.polybar.config."bar/main".font-0 = "Hack Nerd Font:size=10;2"; programs.rofi.font = "Hack Nerd Font 14"; programs.alacritty.settings.font.normal.family = fontName; + programs.kitty.font.name = fontName; }; }; diff --git a/windows/alacritty.yml b/windows/alacritty.yml index fedf71d..4edb4d4 100644 --- a/windows/alacritty.yml +++ b/windows/alacritty.yml @@ -723,7 +723,7 @@ key_bindings: - { key: L, mods: Control|Shift, chars: "\x1F" } # Used for searching nixpkgs in fish_user_key_bindings - { key: N, mods: Control|Shift, chars: "\x11F" } - - { key: K, mods: Control, mode: ~Vi, action: ToggleViMode } + - { key: H, mods: Control|Shift, mode: ~Vi, action: ToggleViMode } - { key: Return, mode: Vi, action: ToggleViMode } # Used to enable $ keybind in Vi mode - { key: 5, mods: Shift, mode: Vi|~Search, action: Last } From 52edaa7d9ca0246d1a14fcaffb9b615124380366 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:16:01 -0400 Subject: [PATCH 082/391] prevent ctrl-q from quitting firefox will this affect macos? --- modules/applications/firefox.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 4d18594..eb39b8e 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -33,6 +33,7 @@ settings = { "browser.aboutConfig.showWarning" = false; "browser.warnOnQuit" = false; + "browser.quitShortcut.disabled" = true; "browser.theme.dark-private-windows" = true; "browser.toolbars.bookmarks.visibility" = "newtab"; "browser.startup.page" = 3; # Restore previous session From 22885f1b27ec274b206980e7f0a606a4e3b25b42 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:16:37 -0400 Subject: [PATCH 083/391] temp: try to show users in lightdm greeter still isn't working unfortunately --- modules/graphical/xorg.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/graphical/xorg.nix b/modules/graphical/xorg.nix index cf3c070..353beab 100644 --- a/modules/graphical/xorg.nix +++ b/modules/graphical/xorg.nix @@ -27,6 +27,11 @@ in { # Make the login screen dark greeters.gtk.theme = gtkTheme; + # Show default user + extraSeatDefaults = '' + greeter-hide-users = false + ''; + }; }; From 7075371b11cdbac0bde2e0b1dcdb84ba26e492f6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:42:32 -0400 Subject: [PATCH 084/391] remove warning about dirty git tree --- hosts/common.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hosts/common.nix b/hosts/common.nix index 5143bce..57451c9 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -65,7 +65,10 @@ in { # Enable features in Nix commands - nix.extraOptions = "experimental-features = nix-command flakes"; + nix.extraOptions = '' + experimental-features = nix-command flakes + warn-dirty = false + ''; # Basic common system packages for all devices environment.systemPackages = with pkgs; [ git vim wget curl ]; From 0448037a6b608b1c6dc99822f822210af78303ad Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:43:34 -0400 Subject: [PATCH 085/391] set kitty tab style to slant --- modules/applications/kitty.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index c41201a..41cfd6f 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -65,6 +65,9 @@ # Window window_padding_width = 4; + tab_bar_edge = "top"; + tab_bar_style = "slant"; + # macos_traditional_fullscreen = true; }; }; From 7bd21254384824547a49f0dbdb181491b4174186 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:43:49 -0400 Subject: [PATCH 086/391] fix: actually use exa for ls --- modules/shell/fish/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shell/fish/default.nix b/modules/shell/fish/default.nix index d4dd300..55e00e0 100644 --- a/modules/shell/fish/default.nix +++ b/modules/shell/fish/default.nix @@ -7,10 +7,11 @@ home-manager.users.${config.user} = { # Packages used in abbreviations and aliases - home.packages = with pkgs; [ curl ]; + home.packages = with pkgs; [ curl exa ]; programs.fish = { enable = true; + shellAliases = { ls = "exa"; }; functions = { commandline-git-commits = { description = "Insert commit into commandline"; @@ -41,7 +42,6 @@ description = "Tidy up JSON using jq"; body = "pbpaste | jq '.' | pbcopy"; # Need to fix for non-macOS }; - ls = { body = "${pkgs.exa}/bin/exa $argv"; }; note = { description = "Edit or create a note"; argumentNames = "filename"; From d7b711ff027ed563f219c6cdf57e38c68ebb6d0d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 14:45:51 -0400 Subject: [PATCH 087/391] replace alacritty with kitty on macos --- hosts/macbook/default.nix | 3 ++- modules/applications/kitty.nix | 5 +---- modules/darwin/default.nix | 1 + .../hammerspoon/Spoons/Launcher.spoon/init.lua | 2 +- modules/darwin/kitty.nix | 16 ++++++++++++++++ modules/darwin/nixpkgs.nix | 4 ++-- modules/darwin/user.nix | 5 +++-- 7 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 modules/darwin/kitty.nix diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 828c732..21132b9 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -25,9 +25,10 @@ darwin.lib.darwinSystem { } ../common.nix ../../modules/darwin + ../../modules/mail ../../modules/applications/alacritty.nix + ../../modules/applications/kitty.nix ../../modules/applications/discord.nix - ../../modules/mail/himalaya.nix ../../modules/repositories/notes.nix ../../modules/programming/nix.nix ../../modules/programming/terraform.nix diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index 41cfd6f..cf5e2bb 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -6,7 +6,6 @@ # programs.rofi.terminal = "${pkgs.kitty}/bin/kitty"; programs.kitty = { enable = true; - darwinLaunchOptions = null; environment = { }; extraConfig = ""; font.size = 14; @@ -63,12 +62,10 @@ ${pkgs.neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; # Window - window_padding_width = 4; + window_padding_width = 6; tab_bar_edge = "top"; tab_bar_style = "slant"; - - # macos_traditional_fullscreen = true; }; }; }; diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index dce21ae..3ce9ed2 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -5,6 +5,7 @@ ./fonts.nix ./hammerspoon.nix ./homebrew.nix + ./kitty.nix ./networking.nix ./nixpkgs.nix ./system.nix diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua index fa27215..2be1b5a 100644 --- a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua @@ -56,7 +56,7 @@ function obj:init() -- Launcher shortcuts self.launcher:bind("ctrl", "space", function() end) self.launcher:bind("", "return", function() - self:switch("Alacritty.app") + self:switch("kitty.app") end) self.launcher:bind("", "C", function() self:switch("Calendar.app") diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix new file mode 100644 index 0000000..5191927 --- /dev/null +++ b/modules/darwin/kitty.nix @@ -0,0 +1,16 @@ +{ config, pkgs, lib, ... }: { + + # MacOS-specific settings for Kitty + home-manager.users.${config.user} = { + programs.kitty = { + darwinLaunchOptions = [ "--start-as=fullscreen" ]; + font.size = lib.mkForce 20; + settings = { + shell = "${pkgs.fish}/bin/fish"; + macos_traditional_fullscreen = true; + macos_quit_when_last_window_closed = true; + }; + }; + }; + +} diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index b3e69ce..cde96ce 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { home-manager.users.${config.user} = { @@ -21,7 +21,7 @@ rebuild-home = lib.mkForce { body = '' git -C ${config.dotfilesPath} add --intent-to-add --all - commandline -r ${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; commandline --function execute ''; }; diff --git a/modules/darwin/user.nix b/modules/darwin/user.nix index 278325f..d3bfbc0 100644 --- a/modules/darwin/user.nix +++ b/modules/darwin/user.nix @@ -1,8 +1,9 @@ { config, pkgs, lib, ... }: { - users.users."${config.user}" = { # macOS user + users.users."${config.user}" = { + # macOS user home = config.homePath; - shell = pkgs.zsh; # Default shell + shell = pkgs.fish; # Default shell }; } From 40424a01027fb85a06a1b3a4749508fc2d8c4191 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 14:46:04 -0400 Subject: [PATCH 088/391] temp: disable visidata bc of python errors --- modules/darwin/utilities.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index 30b509b..07d0a80 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -18,7 +18,7 @@ in { home-manager.users.${config.user} = { home.packages = with pkgs; [ - visidata # CSV inspector + # visidata # CSV inspector dos2unix # Convert Windows text files inetutils # Includes telnet youtube-dl # Convert web videos From 38695b29bd3d0317092bc4d414c8c73c1bc4e79c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:47:33 -0400 Subject: [PATCH 089/391] use shift+enter for completion in terminal --- modules/applications/alacritty.nix | 4 ++-- modules/applications/kitty.nix | 5 ++++- windows/alacritty.yml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index 2c93b60..03f7393 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -23,8 +23,8 @@ key_bindings = [ # Used for word completion in fish_user_key_bindings { - key = "L"; - mods = "Control|Shift"; + key = "Return"; + mods = "Shift"; chars = "\\x1F"; } # Used for searching nixpkgs in fish_user_key_bindings diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index cf5e2bb..87e66af 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -9,7 +9,10 @@ environment = { }; extraConfig = ""; font.size = 14; - keybindings = { }; + keybindings = { + "shift+enter" = "send_text all \\x1F"; + "super+f" = "toggle_fullscreen"; + }; settings = { # Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache) diff --git a/windows/alacritty.yml b/windows/alacritty.yml index 4edb4d4..c030789 100644 --- a/windows/alacritty.yml +++ b/windows/alacritty.yml @@ -720,7 +720,7 @@ shell: # in the order they were defined in. key_bindings: # Used for word completion in fish_user_key_bindings - - { key: L, mods: Control|Shift, chars: "\x1F" } + - { key: Return, mods: Shift, chars: "\x1F" } # Used for searching nixpkgs in fish_user_key_bindings - { key: N, mods: Control|Shift, chars: "\x11F" } - { key: H, mods: Control|Shift, mode: ~Vi, action: ToggleViMode } From 969e89cda34dbd0c4b6db868b4ca8378fe08d336 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:47:42 -0400 Subject: [PATCH 090/391] set kitty to default in i3 --- modules/graphical/i3.nix | 424 ++++++++++++++++++++------------------- 1 file changed, 218 insertions(+), 206 deletions(-) diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index ff9891d..86a7157 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -7,7 +7,8 @@ let lockUpdate = "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.gui.wallpaper} --display 1 --span"; -in { +in +{ config = { @@ -27,213 +28,223 @@ in { xsession.windowManager.i3 = { enable = config.services.xserver.enable; package = pkgs.i3-gaps; - config = let - modifier = "Mod4"; # Super key - ws1 = "1:I"; - ws2 = "2:II"; - ws3 = "3:III"; - ws4 = "4:IV"; - ws5 = "5:V"; - ws6 = "6:VI"; - ws7 = "7:VII"; - ws8 = "8:VIII"; - ws9 = "9:IX"; - ws10 = "10:X"; - in { - modifier = modifier; - assigns = { - "${ws1}" = [{ class = "Firefox"; }]; - "${ws2}" = [{ class = "Alacritty"; }]; - "${ws3}" = [{ class = "discord"; }]; - "${ws4}" = [{ class = "Steam"; }]; - }; - bars = [{ command = "echo"; }]; # Disable i3bar - colors = let - background = config.colorscheme.base00; - inactiveBackground = config.colorscheme.base01; - border = config.colorscheme.base01; - inactiveBorder = config.colorscheme.base01; - text = config.colorscheme.base07; - inactiveText = config.colorscheme.base04; - urgentBackground = config.colorscheme.base08; - indicator = "#00000000"; - in { - background = config.colorscheme.base00; - focused = { - inherit background indicator text border; - childBorder = background; + config = + let + modifier = "Mod4"; # Super key + ws1 = "1:I"; + ws2 = "2:II"; + ws3 = "3:III"; + ws4 = "4:IV"; + ws5 = "5:V"; + ws6 = "6:VI"; + ws7 = "7:VII"; + ws8 = "8:VIII"; + ws9 = "9:IX"; + ws10 = "10:X"; + in + { + modifier = modifier; + assigns = { + "${ws1}" = [{ class = "Firefox"; }]; + "${ws2}" = [{ class = "kitty"; }]; + "${ws3}" = [{ class = "discord"; }]; + "${ws4}" = [{ class = "Steam"; }]; }; - focusedInactive = { - inherit indicator; - background = inactiveBackground; - border = inactiveBorder; - childBorder = inactiveBackground; - text = inactiveText; + bars = [{ command = "echo"; }]; # Disable i3bar + colors = + let + background = config.colorscheme.base00; + inactiveBackground = config.colorscheme.base01; + border = config.colorscheme.base01; + inactiveBorder = config.colorscheme.base01; + text = config.colorscheme.base07; + inactiveText = config.colorscheme.base04; + urgentBackground = config.colorscheme.base08; + indicator = "#00000000"; + in + { + background = config.colorscheme.base00; + focused = { + inherit background indicator text border; + childBorder = background; + }; + focusedInactive = { + inherit indicator; + background = inactiveBackground; + border = inactiveBorder; + childBorder = inactiveBackground; + text = inactiveText; + }; + # placeholder = { }; + unfocused = { + inherit indicator; + background = inactiveBackground; + border = inactiveBorder; + childBorder = inactiveBackground; + text = inactiveText; + }; + urgent = { + inherit text indicator; + background = urgentBackground; + border = urgentBackground; + childBorder = urgentBackground; + }; + }; + floating.modifier = modifier; + focus = { + mouseWarping = true; + newWindow = "urgent"; + followMouse = false; }; - # placeholder = { }; - unfocused = { - inherit indicator; - background = inactiveBackground; - border = inactiveBorder; - childBorder = inactiveBackground; - text = inactiveText; + keybindings = { + + # Adjust screen brightness + "Shift+F12" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; + "Shift+F11" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; + "XF86MonBrightnessUp" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; + "XF86MonBrightnessDown" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; + + # Media player controls + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; + + # Launchers + "${modifier}+Return" = + "exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; + "${modifier}+space" = + "exec --no-startup-id ${config.gui.launcherCommand}"; + "${modifier}+Shift+s" = + "exec --no-startup-id ${config.gui.systemdSearch}"; + "Mod1+Tab" = "exec --no-startup-id ${config.gui.altTabCommand}"; + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+r" = "restart"; + "${modifier}+Shift+q" = '' + exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; + "${modifier}+Shift+x" = "exec ${lockCmd}"; + + # Window options + "${modifier}+q" = "kill"; + "${modifier}+b" = "exec ${config.gui.toggleBarCommand}"; + "${modifier}+f" = "fullscreen toggle"; + "${modifier}+h" = "focus left"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + "${modifier}+l" = "focus right"; + "${modifier}+Left" = "focus left"; + "${modifier}+Down" = "focus down"; + "${modifier}+Up" = "focus up"; + "${modifier}+Right" = "focus right"; + "${modifier}+Shift+h" = "move left"; + "${modifier}+Shift+j" = "move down"; + "${modifier}+Shift+k" = "move up"; + "${modifier}+Shift+l" = "move right"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Right" = "move right"; + + # Tiling + "${modifier}+i" = "split h"; + "${modifier}+v" = "split v"; + "${modifier}+s" = "layout stacking"; + "${modifier}+t" = "layout tabbed"; + "${modifier}+e" = "layout toggle split"; + "${modifier}+Shift+space" = "floating toggle"; + "${modifier}+Control+space" = "focus mode_toggle"; + "${modifier}+a" = "focus parent"; + + # Workspaces + "${modifier}+1" = "workspace ${ws1}"; + "${modifier}+2" = "workspace ${ws2}"; + "${modifier}+3" = "workspace ${ws3}"; + "${modifier}+4" = "workspace ${ws4}"; + "${modifier}+5" = "workspace ${ws5}"; + "${modifier}+6" = "workspace ${ws6}"; + "${modifier}+7" = "workspace ${ws7}"; + "${modifier}+8" = "workspace ${ws8}"; + "${modifier}+9" = "workspace ${ws9}"; + "${modifier}+0" = "workspace ${ws10}"; + + # Move windows + "${modifier}+Shift+1" = + "move container to workspace ${ws1}; workspace ${ws1}"; + "${modifier}+Shift+2" = + "move container to workspace ${ws2}; workspace ${ws2}"; + "${modifier}+Shift+3" = + "move container to workspace ${ws3}; workspace ${ws3}"; + "${modifier}+Shift+4" = + "move container to workspace ${ws4}; workspace ${ws4}"; + "${modifier}+Shift+5" = + "move container to workspace ${ws5}; workspace ${ws5}"; + "${modifier}+Shift+6" = + "move container to workspace ${ws6}; workspace ${ws6}"; + "${modifier}+Shift+7" = + "move container to workspace ${ws7}; workspace ${ws7}"; + "${modifier}+Shift+8" = + "move container to workspace ${ws8}; workspace ${ws8}"; + "${modifier}+Shift+9" = + "move container to workspace ${ws9}; workspace ${ws9}"; + "${modifier}+Shift+0" = + "move container to workspace ${ws10}; workspace ${ws10}"; + + # Move screens + "${modifier}+Control+l" = "move workspace to output right"; + "${modifier}+Control+h" = "move workspace to output left"; + + # Resizing + "${modifier}+r" = ''mode "resize"''; + "${modifier}+Control+Shift+h" = + "resize shrink width 10 px or 10 ppt"; + "${modifier}+Control+Shift+j" = + "resize grow height 10 px or 10 ppt"; + "${modifier}+Control+Shift+k" = + "resize shrink height 10 px or 10 ppt"; + "${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt"; }; - urgent = { - inherit text indicator; - background = urgentBackground; - border = urgentBackground; - childBorder = urgentBackground; + modes = { }; + startup = [ + { + command = "feh --bg-fill ${config.gui.wallpaper}"; + always = true; + notification = false; + } + { + command = + "i3-msg workspace ${ws2}, move workspace to output right"; + notification = false; + } + { + command = + "i3-msg workspace ${ws1}, move workspace to output left"; + notification = false; + } + ]; + window = { + border = 0; + hideEdgeBorders = "smart"; + titlebar = false; }; + workspaceAutoBackAndForth = false; + workspaceOutputAssign = [ ]; + # gaps = { + # bottom = 8; + # top = 8; + # left = 8; + # right = 8; + # horizontal = 15; + # vertical = 15; + # inner = 15; + # outer = 0; + # smartBorders = "off"; + # smartGaps = false; + # }; }; - floating.modifier = modifier; - focus = { - mouseWarping = true; - newWindow = "urgent"; - followMouse = false; - }; - keybindings = { - - # Adjust screen brightness - "Shift+F12" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; - "Shift+F11" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; - "XF86MonBrightnessUp" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; - "XF86MonBrightnessDown" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; - - # Media player controls - "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; - "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; - "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; - - # Launchers - "${modifier}+Return" = - "exec --no-startup-id alacritty; workspace ${ws2}; layout tabbed"; - "${modifier}+space" = - "exec --no-startup-id ${config.gui.launcherCommand}"; - "${modifier}+Shift+s" = - "exec --no-startup-id ${config.gui.systemdSearch}"; - "Mod1+Tab" = "exec --no-startup-id ${config.gui.altTabCommand}"; - "${modifier}+Shift+c" = "reload"; - "${modifier}+Shift+r" = "restart"; - "${modifier}+Shift+q" = '' - exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; - "${modifier}+Shift+x" = "exec ${lockCmd}"; - - # Window options - "${modifier}+q" = "kill"; - "${modifier}+b" = "exec ${config.gui.toggleBarCommand}"; - "${modifier}+f" = "fullscreen toggle"; - "${modifier}+h" = "focus left"; - "${modifier}+j" = "focus down"; - "${modifier}+k" = "focus up"; - "${modifier}+l" = "focus right"; - "${modifier}+Left" = "focus left"; - "${modifier}+Down" = "focus down"; - "${modifier}+Up" = "focus up"; - "${modifier}+Right" = "focus right"; - "${modifier}+Shift+h" = "move left"; - "${modifier}+Shift+j" = "move down"; - "${modifier}+Shift+k" = "move up"; - "${modifier}+Shift+l" = "move right"; - "${modifier}+Shift+Left" = "move left"; - "${modifier}+Shift+Down" = "move down"; - "${modifier}+Shift+Up" = "move up"; - "${modifier}+Shift+Right" = "move right"; - - # Tiling - "${modifier}+i" = "split h"; - "${modifier}+v" = "split v"; - "${modifier}+s" = "layout stacking"; - "${modifier}+t" = "layout tabbed"; - "${modifier}+e" = "layout toggle split"; - "${modifier}+Shift+space" = "floating toggle"; - "${modifier}+Control+space" = "focus mode_toggle"; - "${modifier}+a" = "focus parent"; - - # Workspaces - "${modifier}+1" = "workspace ${ws1}"; - "${modifier}+2" = "workspace ${ws2}"; - "${modifier}+3" = "workspace ${ws3}"; - "${modifier}+4" = "workspace ${ws4}"; - "${modifier}+5" = "workspace ${ws5}"; - "${modifier}+6" = "workspace ${ws6}"; - "${modifier}+7" = "workspace ${ws7}"; - "${modifier}+8" = "workspace ${ws8}"; - "${modifier}+9" = "workspace ${ws9}"; - "${modifier}+0" = "workspace ${ws10}"; - - # Move windows - "${modifier}+Shift+1" = - "move container to workspace ${ws1}; workspace ${ws1}"; - "${modifier}+Shift+2" = - "move container to workspace ${ws2}; workspace ${ws2}"; - "${modifier}+Shift+3" = - "move container to workspace ${ws3}; workspace ${ws3}"; - "${modifier}+Shift+4" = - "move container to workspace ${ws4}; workspace ${ws4}"; - "${modifier}+Shift+5" = - "move container to workspace ${ws5}; workspace ${ws5}"; - "${modifier}+Shift+6" = - "move container to workspace ${ws6}; workspace ${ws6}"; - "${modifier}+Shift+7" = - "move container to workspace ${ws7}; workspace ${ws7}"; - "${modifier}+Shift+8" = - "move container to workspace ${ws8}; workspace ${ws8}"; - "${modifier}+Shift+9" = - "move container to workspace ${ws9}; workspace ${ws9}"; - "${modifier}+Shift+0" = - "move container to workspace ${ws10}; workspace ${ws10}"; - - # Move screens - "${modifier}+Control+l" = "move workspace to output right"; - "${modifier}+Control+h" = "move workspace to output left"; - - # Resizing - "${modifier}+r" = ''mode "resize"''; - "${modifier}+Control+Shift+h" = - "resize shrink width 10 px or 10 ppt"; - "${modifier}+Control+Shift+j" = - "resize grow height 10 px or 10 ppt"; - "${modifier}+Control+Shift+k" = - "resize shrink height 10 px or 10 ppt"; - "${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt"; - }; - modes = { }; - startup = [ - { - command = "feh --bg-fill ${config.gui.wallpaper}"; - always = true; - notification = false; - } - { - command = "i3-msg workspace ${ws1}"; - notification = false; - } - ]; - window = { - border = 0; - hideEdgeBorders = "smart"; - titlebar = false; - }; - workspaceAutoBackAndForth = false; - workspaceOutputAssign = [ ]; - # gaps = { - # bottom = 8; - # top = 8; - # left = 8; - # right = 8; - # horizontal = 15; - # vertical = 15; - # inner = 15; - # outer = 0; - # smartBorders = "off"; - # smartGaps = false; - # }; - }; extraConfig = ""; }; @@ -247,9 +258,10 @@ in { # Update lock screen cache only if cache is empty home.activation.updateLockScreenCache = let cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; - in lib.mkIf config.services.xserver.enable - (config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' + in + lib.mkIf config.services.xserver.enable + (config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then $DRY_RUN_CMD ${lockUpdate} fi From d73ccab00830ec5357a8ed1bd63dda7b8cda13d1 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:40:53 -0400 Subject: [PATCH 091/391] replace pulseaudio with pipewire closes #8 --- modules/hardware/audio.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 31b036b..25e0012 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -33,8 +33,11 @@ in { config = lib.mkIf config.gui.enable { sound.enable = true; - # Enable PulseAudio - hardware.pulseaudio.enable = true; + # Enable PipeWire + services.pipewire = { + enable = true; + pulse.enable = true; + }; # These aren't necessary, but helpful for the user environment.systemPackages = with pkgs; [ From afd44279d27cefb6030efb9e1b4cf06447ff6c16 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:43:14 -0400 Subject: [PATCH 092/391] tweaks to aerc, replace delete with move to trash --- modules/applications/media.nix | 1 + modules/mail/aerc.nix | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/applications/media.nix b/modules/applications/media.nix index 1c8eb7a..c7e69a4 100644 --- a/modules/applications/media.nix +++ b/modules/applications/media.nix @@ -5,6 +5,7 @@ mpv # Video viewer sxiv # Image viewer mupdf # PDF viewer + zathura # PDF viewer ]; }; diff --git a/modules/mail/aerc.nix b/modules/mail/aerc.nix index 348fe75..39ca79a 100644 --- a/modules/mail/aerc.nix +++ b/modules/mail/aerc.nix @@ -51,7 +51,7 @@ "" = ":view"; d = ":prompt 'Really delete this message?' 'delete-message'"; - D = ":delete"; + D = ":move Trash"; A = ":archive flat"; C = ":compose"; @@ -81,7 +81,7 @@ O = ":open"; S = ":save"; "|" = ":pipe"; - D = ":delete"; + D = ":move Trash"; A = ":archive flat"; "" = ":open-link "; @@ -167,13 +167,14 @@ "message/rfc822" = "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; "application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh"; + "application/pdf" = "${pkgs.zathura}/bin/zathura -"; }; }; }; accounts.email.accounts.home.aerc = { enable = true; extraAccounts = { - check-mail = "1m"; + check-mail = "5m"; check-mail-cmd = "${pkgs.isync}/bin/mbsync -a"; }; }; From b2850e8b79155b6e067c15f693a0d0dbf59ae5ab Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:54:29 -0400 Subject: [PATCH 093/391] improve visuals of volume notification --- modules/hardware/audio.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 25e0012..3007b6f 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -55,7 +55,8 @@ in { # Make sure that Volnoti actually starts (home-manager doesn't start # user daemon's automatically) startup = [{ - command = "systemctl --user restart volnoti"; + command = + "systemctl --user restart volnoti --alpha 0.15 --radius 40 --timeout 0.2"; always = true; notification = false; }]; From 41d289c5dbd1a3a2409b7f211d2f8c8b24fd49eb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 2 Nov 2022 21:29:14 -0400 Subject: [PATCH 094/391] refactor colors and options preparing for light mode, even though specializations aren't working --- modules/neovim/.stylua.toml => .stylua.toml | 0 hosts/common.nix | 45 +- hosts/desktop/default.nix | 25 +- modules/applications/alacritty.nix | 36 +- modules/applications/firefox.nix | 42 +- modules/applications/kitty.nix | 70 ++-- modules/colorscheme/gruvbox/default.nix | 55 ++- modules/colorscheme/gruvbox/neovim.lua | 1 + modules/gaming/default.nix | 2 - modules/gaming/legendary.nix | 5 +- modules/gaming/steam.nix | 4 +- modules/graphical/default.nix | 68 +-- modules/graphical/i3.nix | 440 ++++++++++---------- modules/graphical/picom.nix | 83 ++-- modules/graphical/polybar.nix | 38 +- modules/graphical/rofi.nix | 46 +- modules/graphical/xorg.nix | 37 +- modules/neovim/default.nix | 7 +- modules/neovim/init.lua | 1 + 19 files changed, 513 insertions(+), 492 deletions(-) rename modules/neovim/.stylua.toml => .stylua.toml (100%) diff --git a/modules/neovim/.stylua.toml b/.stylua.toml similarity index 100% rename from modules/neovim/.stylua.toml rename to .stylua.toml diff --git a/hosts/common.nix b/hosts/common.nix index 57451c9..a28916a 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -3,9 +3,9 @@ imports = [ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ]; - options = with lib; { - user = mkOption { - type = types.str; + options = rec { + user = lib.mkOption { + type = lib.types.str; description = "Primary user of the system"; }; fullName = lib.mkOption { @@ -27,17 +27,30 @@ default = "/etc/ssh/ssh_host_ed25519_key"; }; gui = { - enable = mkEnableOption { - description = "Enable graphics"; + enable = lib.mkEnableOption { + description = "Enable graphics."; default = false; }; }; - colorscheme = mkOption { - type = types.attrs; - description = "Base16 color scheme"; + theme = { + colors = lib.mkOption { + type = lib.types.attrs; + description = "Base16 color scheme."; + default = (import ../modules/colorscheme/gruvbox).dark; + }; + dark = lib.mkOption { + type = lib.types.bool; + description = "Enable dark mode."; + default = true; + }; }; - homePath = mkOption { - type = types.path; + + # colorscheme = lib.mkOption { + # type = types.attrs; + # description = "Base16 color scheme"; + # }; + homePath = lib.mkOption { + type = lib.types.path; description = "Path of user's home directory."; default = builtins.toPath (if pkgs.stdenv.isDarwin then "/Users/${config.user}" @@ -45,17 +58,17 @@ "/home/${config.user}"); }; - dotfilesPath = mkOption { - type = types.path; + dotfilesPath = lib.mkOption { + type = lib.types.path; description = "Path of dotfiles repository."; default = config.homePath + "/dev/personal/dotfiles"; }; - dotfilesRepo = mkOption { - type = types.str; + dotfilesRepo = lib.mkOption { + type = lib.types.str; description = "Link to dotfiles repository."; }; - unfreePackages = mkOption { - type = types.listOf types.str; + unfreePackages = lib.mkOption { + type = lib.types.listOf lib.types.str; description = "List of unfree packages to allow."; default = [ ]; }; diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 198e910..e351306 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -15,15 +15,13 @@ nixpkgs.lib.nixosSystem { # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; identityFile = "/home/${globals.user}/.ssh/id_ed25519"; - gaming.steam = true; - gaming.legendary = true; - gui = { - enable = true; - compositor.enable = true; - wallpaper = "${wallpapers}/gruvbox/road.jpg"; - gtk.theme = { name = "Adwaita-dark"; }; + gui.enable = true; + theme = { + colors = (import ../../modules/colorscheme/gruvbox).dark; + dark = true; }; - colorscheme = (import ../../modules/colorscheme/gruvbox); + wallpaper = "${wallpapers}/gruvbox/road.jpg"; + gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; passwordHash = "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; } @@ -33,14 +31,17 @@ nixpkgs.lib.nixosSystem { ../../modules/hardware ../../modules/nixos ../../modules/graphical - ../../modules/gaming - ../../modules/applications + ../../modules/gaming/steam.nix + ../../modules/gaming/legendary.nix + ../../modules/applications/media.nix + ../../modules/applications/firefox.nix + ../../modules/applications/kitty.nix + ../../modules/applications/discord.nix + ../../modules/applications/nautilus.nix ../../modules/mail/default.nix ../../modules/repositories/notes.nix ../../modules/services/keybase.nix - ../../modules/services/gnupg.nix ../../modules/services/mullvad.nix ../../modules/programming/nix.nix - ../../modules/programming/haskell.nix ]; } diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index 03f7393..ab6302e 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -54,32 +54,32 @@ ]; colors = { primary = { - background = config.colorscheme.base00; - foreground = config.colorscheme.base05; + background = config.theme.colors.base00; + foreground = config.theme.colors.base05; }; cursor = { text = "#1d2021"; - cursor = config.colorscheme.base05; + cursor = config.theme.colors.base05; }; normal = { black = "#1d2021"; - red = config.colorscheme.base08; - green = config.colorscheme.base0B; - yellow = config.colorscheme.base0A; - blue = config.colorscheme.base0D; - magenta = config.colorscheme.base0E; - cyan = config.colorscheme.base0C; - white = config.colorscheme.base05; + red = config.theme.colors.base08; + green = config.theme.colors.base0B; + yellow = config.theme.colors.base0A; + blue = config.theme.colors.base0D; + magenta = config.theme.colors.base0E; + cyan = config.theme.colors.base0C; + white = config.theme.colors.base05; }; bright = { - black = config.colorscheme.base03; - red = config.colorscheme.base09; - green = config.colorscheme.base01; - yellow = config.colorscheme.base02; - blue = config.colorscheme.base04; - magenta = config.colorscheme.base06; - cyan = config.colorscheme.base0F; - white = config.colorscheme.base07; + black = config.theme.colors.base03; + red = config.theme.colors.base09; + green = config.theme.colors.base01; + yellow = config.theme.colors.base02; + blue = config.theme.colors.base04; + magenta = config.theme.colors.base06; + cyan = config.theme.colors.base0F; + white = config.theme.colors.base07; }; }; draw_bold_text_with_bright_colors = false; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index eb39b8e..723d8d6 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -48,65 +48,65 @@ }; userChrome = '' :root { - --focus-outline-color: ${config.colorscheme.base04} !important; - --toolbar-color: ${config.colorscheme.base07} !important; + --focus-outline-color: ${config.theme.colors.base04} !important; + --toolbar-color: ${config.theme.colors.base07} !important; --tab-min-height: 30px !important; } /* Background of tab bar */ .toolbar-items { - background-color: ${config.colorscheme.base00} !important; + background-color: ${config.theme.colors.base00} !important; } /* Tabs themselves */ .tabbrowser-tab .tab-stack { border-radius: 5px 5px 0 0; overflow: hidden; - background-color: ${config.colorscheme.base00}; - color: ${config.colorscheme.base06} !important; + background-color: ${config.theme.colors.base00}; + color: ${config.theme.colors.base06} !important; } .tab-content { border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 40%, transparent); border-radius: 5px 5px 0 0; - background-color: ${config.colorscheme.base00}; - color: ${config.colorscheme.base06} !important; + background-color: ${config.theme.colors.base00}; + color: ${config.theme.colors.base06} !important; } .tab-content[selected=true] { border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 25%, transparent); - background-color: ${config.colorscheme.base01} !important; - color: ${config.colorscheme.base07} !important; + background-color: ${config.theme.colors.base01} !important; + color: ${config.theme.colors.base07} !important; } /* Below tab bar */ #nav-bar { - background: ${config.colorscheme.base01} !important; + background: ${config.theme.colors.base01} !important; } /* URL bar in nav bar */ #urlbar[focused=true] { - color: ${config.colorscheme.base07} !important; - background: ${config.colorscheme.base02} !important; - caret-color: ${config.colorscheme.base05} !important; + color: ${config.theme.colors.base07} !important; + background: ${config.theme.colors.base02} !important; + caret-color: ${config.theme.colors.base05} !important; } #urlbar:not([focused=true]) { - color: ${config.colorscheme.base04} !important; - background: ${config.colorscheme.base02} !important; + color: ${config.theme.colors.base04} !important; + background: ${config.theme.colors.base02} !important; } #urlbar ::-moz-selection { - color: ${config.colorscheme.base07} !important; - background: ${config.colorscheme.base02} !important; + color: ${config.theme.colors.base07} !important; + background: ${config.theme.colors.base02} !important; } #urlbar-input-container { - border: 1px solid ${config.colorscheme.base01} !important; + border: 1px solid ${config.theme.colors.base01} !important; } #urlbar-background { - background: ${config.colorscheme.base01} !important; + background: ${config.theme.colors.base01} !important; } /* Text in URL bar */ #urlbar-input, #urlbar-scheme, .searchbar-textbox { - color: ${config.colorscheme.base07} !important; + color: ${config.theme.colors.base07} !important; } ''; userContent = '' @-moz-document url-prefix(about:blank) { * { - background-color:${config.colorscheme.base01} !important; + background-color:${config.theme.colors.base01} !important; } } ''; diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index 87e66af..82e4cf7 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -16,47 +16,47 @@ settings = { # Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache) - background = config.colorscheme.base00; - foreground = config.colorscheme.base05; - selection_background = config.colorscheme.base05; - selection_foreground = config.colorscheme.base00; - url_color = config.colorscheme.base04; - cursor = config.colorscheme.base05; - active_border_color = config.colorscheme.base03; - inactive_border_color = config.colorscheme.base01; - active_tab_background = config.colorscheme.base00; - active_tab_foreground = config.colorscheme.base05; - inactive_tab_background = config.colorscheme.base01; - inactive_tab_foreground = config.colorscheme.base04; - tab_bar_background = config.colorscheme.base01; + background = config.theme.colors.base00; + foreground = config.theme.colors.base05; + selection_background = config.theme.colors.base05; + selection_foreground = config.theme.colors.base00; + url_color = config.theme.colors.base04; + cursor = config.theme.colors.base05; + active_border_color = config.theme.colors.base03; + inactive_border_color = config.theme.colors.base01; + active_tab_background = config.theme.colors.base00; + active_tab_foreground = config.theme.colors.base05; + inactive_tab_background = config.theme.colors.base01; + inactive_tab_foreground = config.theme.colors.base04; + tab_bar_background = config.theme.colors.base01; # normal - color0 = config.colorscheme.base00; - color1 = config.colorscheme.base08; - color2 = config.colorscheme.base0B; - color3 = config.colorscheme.base0A; - color4 = config.colorscheme.base0D; - color5 = config.colorscheme.base0E; - color6 = config.colorscheme.base0C; - color7 = config.colorscheme.base05; + color0 = config.theme.colors.base00; + color1 = config.theme.colors.base08; + color2 = config.theme.colors.base0B; + color3 = config.theme.colors.base0A; + color4 = config.theme.colors.base0D; + color5 = config.theme.colors.base0E; + color6 = config.theme.colors.base0C; + color7 = config.theme.colors.base05; # bright - color8 = config.colorscheme.base03; - color9 = config.colorscheme.base08; - color10 = config.colorscheme.base0B; - color11 = config.colorscheme.base0A; - color12 = config.colorscheme.base0D; - color13 = config.colorscheme.base0E; - color14 = config.colorscheme.base0C; - color15 = config.colorscheme.base07; + color8 = config.theme.colors.base03; + color9 = config.theme.colors.base08; + color10 = config.theme.colors.base0B; + color11 = config.theme.colors.base0A; + color12 = config.theme.colors.base0D; + color13 = config.theme.colors.base0E; + color14 = config.theme.colors.base0C; + color15 = config.theme.colors.base07; # extended base16 colors - color16 = config.colorscheme.base09; - color17 = config.colorscheme.base0F; - color18 = config.colorscheme.base01; - color19 = config.colorscheme.base02; - color20 = config.colorscheme.base04; - color21 = config.colorscheme.base06; + color16 = config.theme.colors.base09; + color17 = config.theme.colors.base0F; + color18 = config.theme.colors.base01; + color19 = config.theme.colors.base02; + color20 = config.theme.colors.base04; + color21 = config.theme.colors.base06; # Scrollback scrolling_lines = 10000; diff --git a/modules/colorscheme/gruvbox/default.nix b/modules/colorscheme/gruvbox/default.nix index 70fcd26..3567f00 100644 --- a/modules/colorscheme/gruvbox/default.nix +++ b/modules/colorscheme/gruvbox/default.nix @@ -2,21 +2,42 @@ name = "gruvbox"; # Dark, Medium author = "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)"; - base00 = "#282828"; # ---- - base01 = "#3c3836"; # --- - base02 = "#504945"; # -- - base03 = "#665c54"; # - - base04 = "#bdae93"; # + - base05 = "#d5c4a1"; # ++ - base06 = "#ebdbb2"; # +++ - base07 = "#fbf1c7"; # ++++ - base08 = "#fb4934"; # red - base09 = "#fe8019"; # orange - base0A = "#fabd2f"; # yellow - base0B = "#b8bb26"; # green - base0C = "#8ec07c"; # aqua/cyan - base0D = "#83a598"; # blue - base0E = "#d3869b"; # purple - base0F = "#d65d0e"; # brown - neovimConfig = ./neovim.lua; + dark = { + base00 = "#282828"; # ---- + base01 = "#3c3836"; # --- + base02 = "#504945"; # -- + base03 = "#665c54"; # - + base04 = "#bdae93"; # + + base05 = "#d5c4a1"; # ++ + base06 = "#ebdbb2"; # +++ + base07 = "#fbf1c7"; # ++++ + base08 = "#fb4934"; # red + base09 = "#fe8019"; # orange + base0A = "#fabd2f"; # yellow + base0B = "#b8bb26"; # green + base0C = "#8ec07c"; # aqua/cyan + base0D = "#83a598"; # blue + base0E = "#d3869b"; # purple + base0F = "#d65d0e"; # brown + neovimConfig = ./neovim.lua; + }; + light = { + base00 = "#fbf1c7"; # ---- + base01 = "#ebdbb2"; # --- + base02 = "#d5c4a1"; # -- + base03 = "#bdae93"; # - + base04 = "#665c54"; # + + base05 = "#504945"; # ++ + base06 = "#3c3836"; # +++ + base07 = "#282828"; # ++++ + base08 = "#9d0006"; # red + base09 = "#af3a03"; # orange + base0A = "#b57614"; # yellow + base0B = "#79740e"; # green + base0C = "#427b58"; # aqua/cyan + base0D = "#076678"; # blue + base0E = "#8f3f71"; # purple + base0F = "#d65d0e"; # brown + neovimConfig = ./neovim-light.lua; + }; } diff --git a/modules/colorscheme/gruvbox/neovim.lua b/modules/colorscheme/gruvbox/neovim.lua index 086b0cb..db3f77c 100644 --- a/modules/colorscheme/gruvbox/neovim.lua +++ b/modules/colorscheme/gruvbox/neovim.lua @@ -6,6 +6,7 @@ M.packer = function(use) config = function() vim.g.gruvbox_italicize_strings = 0 vim.cmd("colorscheme gruvbox8") + vim.cmd("set background=dark") end, }) end diff --git a/modules/gaming/default.nix b/modules/gaming/default.nix index 7b26dc6..e074730 100644 --- a/modules/gaming/default.nix +++ b/modules/gaming/default.nix @@ -1,7 +1,5 @@ { config, ... }: { - imports = [ ./leagueoflegends.nix ./lutris.nix ./steam.nix ./legendary.nix ]; - config = { hardware.opengl = { enable = true; diff --git a/modules/gaming/legendary.nix b/modules/gaming/legendary.nix index 11269bc..f8ce849 100644 --- a/modules/gaming/legendary.nix +++ b/modules/gaming/legendary.nix @@ -4,10 +4,9 @@ let home-packages = config.home-manager.users.${config.user}.home.packages; in { - options.gaming.legendary = - lib.mkEnableOption "Legendary - Epic Games Launcher"; + imports = [ ./. ]; - config = lib.mkIf config.gaming.legendary { + config = { environment.systemPackages = with pkgs; [ legendary-gl rare # GUI for Legendary (not working) diff --git a/modules/gaming/steam.nix b/modules/gaming/steam.nix index 6e1996b..61cf5c5 100644 --- a/modules/gaming/steam.nix +++ b/modules/gaming/steam.nix @@ -1,8 +1,8 @@ { config, pkgs, lib, ... }: { - options.gaming.steam = lib.mkEnableOption "Steam"; + imports = [ ./. ]; - config = lib.mkIf config.gaming.steam { + config = { hardware.steam-hardware.enable = true; unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ]; environment.systemPackages = with pkgs; [ diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix index ea6a7a8..9d6c8e6 100644 --- a/modules/graphical/default.nix +++ b/modules/graphical/default.nix @@ -1,53 +1,29 @@ { lib, ... }: { - imports = [ - ./xorg.nix - ./fonts.nix - ./i3.nix - ./polybar.nix - ./picom.nix - # ./dmenu.nix - ./rofi.nix - ]; + imports = + [ ./xorg.nix ./fonts.nix ./i3.nix ./polybar.nix ./picom.nix ./rofi.nix ]; - options = with lib; { + options = { - gui = { - compositor.enable = mkEnableOption { - description = "Enable transparency, blur, shadows"; - default = false; - }; - launcherCommand = mkOption { - type = types.str; - description = "Command to use for launching"; - }; - systemdSearch = mkOption { - type = types.str; - description = "Command to use for interacting with systemd"; - }; - altTabCommand = mkOption { - type = types.str; - description = "Command to use for choosing windows"; - }; - toggleBarCommand = lib.mkOption { - type = lib.types.str; - description = "Command to hide and show the status bar."; - }; - gtk.theme = { - name = mkOption { - type = types.str; - description = "Theme name for GTK applications"; - }; - package = mkOption { - type = types.str; - description = "Theme package name for GTK applications"; - default = "gnome-themes-extra"; - }; - }; - wallpaper = mkOption { - type = types.path; - description = "Wallpaper background image file"; - }; + launcherCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for launching"; + }; + systemdSearch = lib.mkOption { + type = lib.types.str; + description = "Command to use for interacting with systemd"; + }; + altTabCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for choosing windows"; + }; + toggleBarCommand = lib.mkOption { + type = lib.types.str; + description = "Command to hide and show the status bar."; + }; + wallpaper = lib.mkOption { + type = lib.types.path; + description = "Wallpaper background image file"; }; }; diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index 86a7157..a7d368b 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -5,10 +5,9 @@ let lockCmd = "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span"; lockUpdate = - "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.gui.wallpaper} --display 1 --span"; + "${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span"; -in -{ +in { config = { @@ -28,223 +27,219 @@ in xsession.windowManager.i3 = { enable = config.services.xserver.enable; package = pkgs.i3-gaps; - config = - let - modifier = "Mod4"; # Super key - ws1 = "1:I"; - ws2 = "2:II"; - ws3 = "3:III"; - ws4 = "4:IV"; - ws5 = "5:V"; - ws6 = "6:VI"; - ws7 = "7:VII"; - ws8 = "8:VIII"; - ws9 = "9:IX"; - ws10 = "10:X"; - in - { - modifier = modifier; - assigns = { - "${ws1}" = [{ class = "Firefox"; }]; - "${ws2}" = [{ class = "kitty"; }]; - "${ws3}" = [{ class = "discord"; }]; - "${ws4}" = [{ class = "Steam"; }]; - }; - bars = [{ command = "echo"; }]; # Disable i3bar - colors = - let - background = config.colorscheme.base00; - inactiveBackground = config.colorscheme.base01; - border = config.colorscheme.base01; - inactiveBorder = config.colorscheme.base01; - text = config.colorscheme.base07; - inactiveText = config.colorscheme.base04; - urgentBackground = config.colorscheme.base08; - indicator = "#00000000"; - in - { - background = config.colorscheme.base00; - focused = { - inherit background indicator text border; - childBorder = background; - }; - focusedInactive = { - inherit indicator; - background = inactiveBackground; - border = inactiveBorder; - childBorder = inactiveBackground; - text = inactiveText; - }; - # placeholder = { }; - unfocused = { - inherit indicator; - background = inactiveBackground; - border = inactiveBorder; - childBorder = inactiveBackground; - text = inactiveText; - }; - urgent = { - inherit text indicator; - background = urgentBackground; - border = urgentBackground; - childBorder = urgentBackground; - }; - }; - floating.modifier = modifier; - focus = { - mouseWarping = true; - newWindow = "urgent"; - followMouse = false; - }; - keybindings = { - - # Adjust screen brightness - "Shift+F12" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; - "Shift+F11" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; - "XF86MonBrightnessUp" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; - "XF86MonBrightnessDown" = - "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; - - # Media player controls - "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; - "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; - "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; - - # Launchers - "${modifier}+Return" = - "exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; - "${modifier}+space" = - "exec --no-startup-id ${config.gui.launcherCommand}"; - "${modifier}+Shift+s" = - "exec --no-startup-id ${config.gui.systemdSearch}"; - "Mod1+Tab" = "exec --no-startup-id ${config.gui.altTabCommand}"; - "${modifier}+Shift+c" = "reload"; - "${modifier}+Shift+r" = "restart"; - "${modifier}+Shift+q" = '' - exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; - "${modifier}+Shift+x" = "exec ${lockCmd}"; - - # Window options - "${modifier}+q" = "kill"; - "${modifier}+b" = "exec ${config.gui.toggleBarCommand}"; - "${modifier}+f" = "fullscreen toggle"; - "${modifier}+h" = "focus left"; - "${modifier}+j" = "focus down"; - "${modifier}+k" = "focus up"; - "${modifier}+l" = "focus right"; - "${modifier}+Left" = "focus left"; - "${modifier}+Down" = "focus down"; - "${modifier}+Up" = "focus up"; - "${modifier}+Right" = "focus right"; - "${modifier}+Shift+h" = "move left"; - "${modifier}+Shift+j" = "move down"; - "${modifier}+Shift+k" = "move up"; - "${modifier}+Shift+l" = "move right"; - "${modifier}+Shift+Left" = "move left"; - "${modifier}+Shift+Down" = "move down"; - "${modifier}+Shift+Up" = "move up"; - "${modifier}+Shift+Right" = "move right"; - - # Tiling - "${modifier}+i" = "split h"; - "${modifier}+v" = "split v"; - "${modifier}+s" = "layout stacking"; - "${modifier}+t" = "layout tabbed"; - "${modifier}+e" = "layout toggle split"; - "${modifier}+Shift+space" = "floating toggle"; - "${modifier}+Control+space" = "focus mode_toggle"; - "${modifier}+a" = "focus parent"; - - # Workspaces - "${modifier}+1" = "workspace ${ws1}"; - "${modifier}+2" = "workspace ${ws2}"; - "${modifier}+3" = "workspace ${ws3}"; - "${modifier}+4" = "workspace ${ws4}"; - "${modifier}+5" = "workspace ${ws5}"; - "${modifier}+6" = "workspace ${ws6}"; - "${modifier}+7" = "workspace ${ws7}"; - "${modifier}+8" = "workspace ${ws8}"; - "${modifier}+9" = "workspace ${ws9}"; - "${modifier}+0" = "workspace ${ws10}"; - - # Move windows - "${modifier}+Shift+1" = - "move container to workspace ${ws1}; workspace ${ws1}"; - "${modifier}+Shift+2" = - "move container to workspace ${ws2}; workspace ${ws2}"; - "${modifier}+Shift+3" = - "move container to workspace ${ws3}; workspace ${ws3}"; - "${modifier}+Shift+4" = - "move container to workspace ${ws4}; workspace ${ws4}"; - "${modifier}+Shift+5" = - "move container to workspace ${ws5}; workspace ${ws5}"; - "${modifier}+Shift+6" = - "move container to workspace ${ws6}; workspace ${ws6}"; - "${modifier}+Shift+7" = - "move container to workspace ${ws7}; workspace ${ws7}"; - "${modifier}+Shift+8" = - "move container to workspace ${ws8}; workspace ${ws8}"; - "${modifier}+Shift+9" = - "move container to workspace ${ws9}; workspace ${ws9}"; - "${modifier}+Shift+0" = - "move container to workspace ${ws10}; workspace ${ws10}"; - - # Move screens - "${modifier}+Control+l" = "move workspace to output right"; - "${modifier}+Control+h" = "move workspace to output left"; - - # Resizing - "${modifier}+r" = ''mode "resize"''; - "${modifier}+Control+Shift+h" = - "resize shrink width 10 px or 10 ppt"; - "${modifier}+Control+Shift+j" = - "resize grow height 10 px or 10 ppt"; - "${modifier}+Control+Shift+k" = - "resize shrink height 10 px or 10 ppt"; - "${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt"; - }; - modes = { }; - startup = [ - { - command = "feh --bg-fill ${config.gui.wallpaper}"; - always = true; - notification = false; - } - { - command = - "i3-msg workspace ${ws2}, move workspace to output right"; - notification = false; - } - { - command = - "i3-msg workspace ${ws1}, move workspace to output left"; - notification = false; - } - ]; - window = { - border = 0; - hideEdgeBorders = "smart"; - titlebar = false; - }; - workspaceAutoBackAndForth = false; - workspaceOutputAssign = [ ]; - # gaps = { - # bottom = 8; - # top = 8; - # left = 8; - # right = 8; - # horizontal = 15; - # vertical = 15; - # inner = 15; - # outer = 0; - # smartBorders = "off"; - # smartGaps = false; - # }; + config = let + modifier = "Mod4"; # Super key + ws1 = "1:I"; + ws2 = "2:II"; + ws3 = "3:III"; + ws4 = "4:IV"; + ws5 = "5:V"; + ws6 = "6:VI"; + ws7 = "7:VII"; + ws8 = "8:VIII"; + ws9 = "9:IX"; + ws10 = "10:X"; + in { + modifier = modifier; + assigns = { + "${ws1}" = [{ class = "Firefox"; }]; + "${ws2}" = [{ class = "kitty"; }]; + "${ws3}" = [{ class = "discord"; }]; + "${ws4}" = [{ class = "Steam"; }]; }; + bars = [{ command = "echo"; }]; # Disable i3bar + colors = let + background = config.theme.colors.base00; + inactiveBackground = config.theme.colors.base01; + border = config.theme.colors.base01; + inactiveBorder = config.theme.colors.base01; + text = config.theme.colors.base07; + inactiveText = config.theme.colors.base04; + urgentBackground = config.theme.colors.base08; + indicator = "#00000000"; + in { + background = config.theme.colors.base00; + focused = { + inherit background indicator text border; + childBorder = background; + }; + focusedInactive = { + inherit indicator; + background = inactiveBackground; + border = inactiveBorder; + childBorder = inactiveBackground; + text = inactiveText; + }; + # placeholder = { }; + unfocused = { + inherit indicator; + background = inactiveBackground; + border = inactiveBorder; + childBorder = inactiveBackground; + text = inactiveText; + }; + urgent = { + inherit text indicator; + background = urgentBackground; + border = urgentBackground; + childBorder = urgentBackground; + }; + }; + floating.modifier = modifier; + focus = { + mouseWarping = true; + newWindow = "urgent"; + followMouse = false; + }; + keybindings = { + + # Adjust screen brightness + "Shift+F12" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; + "Shift+F11" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; + "XF86MonBrightnessUp" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30"; + "XF86MonBrightnessDown" = + "exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30"; + + # Media player controls + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; + + # Launchers + "${modifier}+Return" = + "exec --no-startup-id kitty; workspace ${ws2}; layout tabbed"; + "${modifier}+space" = + "exec --no-startup-id ${config.launcherCommand}"; + "${modifier}+Shift+s" = + "exec --no-startup-id ${config.systemdSearch}"; + "Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+r" = "restart"; + "${modifier}+Shift+q" = '' + exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; + "${modifier}+Shift+x" = "exec ${lockCmd}"; + + # Window options + "${modifier}+q" = "kill"; + "${modifier}+b" = "exec ${config.toggleBarCommand}"; + "${modifier}+f" = "fullscreen toggle"; + "${modifier}+h" = "focus left"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + "${modifier}+l" = "focus right"; + "${modifier}+Left" = "focus left"; + "${modifier}+Down" = "focus down"; + "${modifier}+Up" = "focus up"; + "${modifier}+Right" = "focus right"; + "${modifier}+Shift+h" = "move left"; + "${modifier}+Shift+j" = "move down"; + "${modifier}+Shift+k" = "move up"; + "${modifier}+Shift+l" = "move right"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Right" = "move right"; + + # Tiling + "${modifier}+i" = "split h"; + "${modifier}+v" = "split v"; + "${modifier}+s" = "layout stacking"; + "${modifier}+t" = "layout tabbed"; + "${modifier}+e" = "layout toggle split"; + "${modifier}+Shift+space" = "floating toggle"; + "${modifier}+Control+space" = "focus mode_toggle"; + "${modifier}+a" = "focus parent"; + + # Workspaces + "${modifier}+1" = "workspace ${ws1}"; + "${modifier}+2" = "workspace ${ws2}"; + "${modifier}+3" = "workspace ${ws3}"; + "${modifier}+4" = "workspace ${ws4}"; + "${modifier}+5" = "workspace ${ws5}"; + "${modifier}+6" = "workspace ${ws6}"; + "${modifier}+7" = "workspace ${ws7}"; + "${modifier}+8" = "workspace ${ws8}"; + "${modifier}+9" = "workspace ${ws9}"; + "${modifier}+0" = "workspace ${ws10}"; + + # Move windows + "${modifier}+Shift+1" = + "move container to workspace ${ws1}; workspace ${ws1}"; + "${modifier}+Shift+2" = + "move container to workspace ${ws2}; workspace ${ws2}"; + "${modifier}+Shift+3" = + "move container to workspace ${ws3}; workspace ${ws3}"; + "${modifier}+Shift+4" = + "move container to workspace ${ws4}; workspace ${ws4}"; + "${modifier}+Shift+5" = + "move container to workspace ${ws5}; workspace ${ws5}"; + "${modifier}+Shift+6" = + "move container to workspace ${ws6}; workspace ${ws6}"; + "${modifier}+Shift+7" = + "move container to workspace ${ws7}; workspace ${ws7}"; + "${modifier}+Shift+8" = + "move container to workspace ${ws8}; workspace ${ws8}"; + "${modifier}+Shift+9" = + "move container to workspace ${ws9}; workspace ${ws9}"; + "${modifier}+Shift+0" = + "move container to workspace ${ws10}; workspace ${ws10}"; + + # Move screens + "${modifier}+Control+l" = "move workspace to output right"; + "${modifier}+Control+h" = "move workspace to output left"; + + # Resizing + "${modifier}+r" = ''mode "resize"''; + "${modifier}+Control+Shift+h" = + "resize shrink width 10 px or 10 ppt"; + "${modifier}+Control+Shift+j" = + "resize grow height 10 px or 10 ppt"; + "${modifier}+Control+Shift+k" = + "resize shrink height 10 px or 10 ppt"; + "${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt"; + }; + modes = { }; + startup = [ + { + command = "feh --bg-fill ${config.wallpaper}"; + always = true; + notification = false; + } + { + command = + "i3-msg workspace ${ws2}, move workspace to output right"; + notification = false; + } + { + command = + "i3-msg workspace ${ws1}, move workspace to output left"; + notification = false; + } + ]; + window = { + border = 0; + hideEdgeBorders = "smart"; + titlebar = false; + }; + workspaceAutoBackAndForth = false; + workspaceOutputAssign = [ ]; + # gaps = { + # bottom = 8; + # top = 8; + # left = 8; + # right = 8; + # horizontal = 15; + # vertical = 15; + # inner = 15; + # outer = 0; + # smartBorders = "off"; + # smartGaps = false; + # }; + }; extraConfig = ""; }; @@ -258,10 +253,9 @@ in # Update lock screen cache only if cache is empty home.activation.updateLockScreenCache = let cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; - in - lib.mkIf config.services.xserver.enable - (config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' + in lib.mkIf config.services.xserver.enable + (config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then $DRY_RUN_CMD ${lockUpdate} fi diff --git a/modules/graphical/picom.nix b/modules/graphical/picom.nix index c9ad371..47db1fa 100644 --- a/modules/graphical/picom.nix +++ b/modules/graphical/picom.nix @@ -1,50 +1,49 @@ { config, lib, ... }: { - config = - lib.mkIf (config.services.xserver.enable && config.gui.compositor.enable) { - home-manager.users.${config.user} = { + config = lib.mkIf (config.services.xserver.enable) { + home-manager.users.${config.user} = { - services.picom = { - enable = true; - backend = "glx"; - settings = { - blur = false; - blurExclude = [ ]; - inactiveDim = "0.05"; - noDNDShadow = false; - noDockShadow = false; - # shadow-radius = 20 - # ''; - # shadow-radius = 20 - # corner-radius = 10 - # blur-size = 20 - # rounded-corners-exclude = [ - # "window_type = 'dock'", - # "class_g = 'i3-frame'" - # ] - # ''; - }; - fade = false; - experimentalBackends = true; - inactiveOpacity = 1.0; - menuOpacity = 1.0; - opacityRules = [ - "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows - ]; - shadow = false; - shadowExclude = [ ]; - shadowOffsets = [ (-10) (-10) ]; - shadowOpacity = 0.5; - vSync = true; + services.picom = { + enable = true; + backend = "glx"; + settings = { + blur = false; + blurExclude = [ ]; + inactiveDim = "0.05"; + noDNDShadow = false; + noDockShadow = false; + # shadow-radius = 20 + # ''; + # shadow-radius = 20 + # corner-radius = 10 + # blur-size = 20 + # rounded-corners-exclude = [ + # "window_type = 'dock'", + # "class_g = 'i3-frame'" + # ] + # ''; }; - - xsession.windowManager.i3.config.startup = [{ - command = "systemctl --user restart picom"; - always = true; - notification = false; - }]; - + fade = false; + experimentalBackends = true; + inactiveOpacity = 1.0; + menuOpacity = 1.0; + opacityRules = [ + "0:_NET_WM_STATE@[0]:32a = '_NET_WM_STATE_HIDDEN'" # Hide tabbed windows + ]; + shadow = false; + shadowExclude = [ ]; + shadowOffsets = [ (-10) (-10) ]; + shadowOpacity = 0.5; + vSync = true; }; + + xsession.windowManager.i3.config.startup = [{ + command = "systemctl --user restart picom"; + always = true; + notification = false; + }]; + }; + }; } diff --git a/modules/graphical/polybar.nix b/modules/graphical/polybar.nix index 761d2e7..9098326 100644 --- a/modules/graphical/polybar.nix +++ b/modules/graphical/polybar.nix @@ -2,7 +2,7 @@ config = lib.mkIf config.services.xserver.enable { - gui.toggleBarCommand = "polybar-msg cmd toggle"; + toggleBarCommand = "polybar-msg cmd toggle"; home-manager.users.${config.user} = { @@ -23,14 +23,14 @@ # offset-y = -5; # offset-y = "5%"; # dpi = 96; - background = config.colorscheme.base01; - foreground = config.colorscheme.base05; + background = config.theme.colors.base01; + foreground = config.theme.colors.base05; line-size = "3pt"; border-top-size = 0; border-right-size = 0; border-left-size = 0; border-bottom-size = "4pt"; - border-color = config.colorscheme.base00; + border-color = config.theme.colors.base00; padding-left = 2; padding-right = 2; module-margin = 1; @@ -58,35 +58,35 @@ fuzzy-match = true; format = " "; label-focused = "%name%"; - label-focused-foreground = config.colorscheme.base01; - label-focused-background = config.colorscheme.base05; - label-focused-underline = config.colorscheme.base03; + label-focused-foreground = config.theme.colors.base01; + label-focused-background = config.theme.colors.base05; + label-focused-underline = config.theme.colors.base03; label-focused-padding = padding; label-unfocused = "%name%"; label-unfocused-padding = padding; label-visible = "%name%"; - label-visible-underline = config.colorscheme.base01; + label-visible-underline = config.theme.colors.base01; label-visible-padding = padding; label-urgent = "%name%"; - label-urgent-foreground = config.colorscheme.base00; - label-urgent-background = config.colorscheme.base08; - label-urgent-underline = config.colorscheme.base0F; + label-urgent-foreground = config.theme.colors.base00; + label-urgent-background = config.theme.colors.base08; + label-urgent-underline = config.theme.colors.base0F; label-urgent-padding = padding; }; "module/xworkspaces" = { type = "internal/xworkspaces"; label-active = "%name%"; - label-active-background = config.colorscheme.base05; - label-active-foreground = config.colorscheme.base01; - label-active-underline = config.colorscheme.base03; + label-active-background = config.theme.colors.base05; + label-active-foreground = config.theme.colors.base01; + label-active-underline = config.theme.colors.base03; label-active-padding = 1; label-occupied = "%name%"; label-occupied-padding = 1; label-urgent = "%name%"; - label-urgent-background = config.colorscheme.base08; + label-urgent-background = config.theme.colors.base08; label-urgent-padding = 1; label-empty = "%name%"; - label-empty-foreground = config.colorscheme.base06; + label-empty-foreground = config.theme.colors.base06; label-empty-padding = 1; }; "module/xwindow" = { @@ -108,10 +108,10 @@ format-volume = " "; # format-volume-background = colors.background; # label-volume-background = colors.background; - format-volume-foreground = config.colorscheme.base0B; + format-volume-foreground = config.theme.colors.base0B; label-volume = "%percentage%%"; label-muted = "ﱝ ---"; - label-muted-foreground = config.colorscheme.base03; + label-muted-foreground = config.theme.colors.base03; ramp-volume-0 = ""; ramp-volume-1 = "墳"; ramp-volume-2 = ""; @@ -163,7 +163,7 @@ date = "%d %b %l:%M %p"; date-alt = "%Y-%m-%d %H:%M:%S"; label = "%date%"; - label-foreground = config.colorscheme.base0A; + label-foreground = config.theme.colors.base0A; # format-background = colors.background; }; "settings" = { diff --git a/modules/graphical/rofi.nix b/modules/graphical/rofi.nix index 471d8ae..5a8674a 100644 --- a/modules/graphical/rofi.nix +++ b/modules/graphical/rofi.nix @@ -25,19 +25,19 @@ # Inspired by https://github.com/sherubthakur/dotfiles/blob/master/users/modules/desktop-environment/rofi/launcher.rasi "*" = { - background-color = mkLiteral config.colorscheme.base00; - foreground-color = mkLiteral config.colorscheme.base07; - text-color = mkLiteral config.colorscheme.base07; - border-color = mkLiteral config.colorscheme.base04; + background-color = mkLiteral config.theme.colors.base00; + foreground-color = mkLiteral config.theme.colors.base07; + text-color = mkLiteral config.theme.colors.base07; + border-color = mkLiteral config.theme.colors.base04; }; # Holds the entire window "#window" = { transparency = "real"; - background-color = mkLiteral config.colorscheme.base00; - text-color = mkLiteral config.colorscheme.base07; + background-color = mkLiteral config.theme.colors.base00; + text-color = mkLiteral config.theme.colors.base07; border = mkLiteral "4px"; - border-color = mkLiteral config.colorscheme.base04; + border-color = mkLiteral config.theme.colors.base04; border-radius = mkLiteral "4px"; width = mkLiteral "850px"; padding = mkLiteral "15px"; @@ -45,10 +45,10 @@ # Wrapper around bar and results "#mainbox" = { - background-color = mkLiteral config.colorscheme.base00; + background-color = mkLiteral config.theme.colors.base00; border = mkLiteral "0px"; border-radius = mkLiteral "0px"; - border-color = mkLiteral config.colorscheme.base04; + border-color = mkLiteral config.theme.colors.base04; children = map mkLiteral [ "inputbar" "listview" ]; spacing = mkLiteral "10px"; padding = mkLiteral "10px"; @@ -59,7 +59,7 @@ expand = false; str = ":"; margin = mkLiteral "0px 0.3em 0em 0em"; - text-color = mkLiteral config.colorscheme.base07; + text-color = mkLiteral config.theme.colors.base07; }; # Command prompt left of the input @@ -67,7 +67,7 @@ # Actual text box "#entry" = { - placeholder-color = mkLiteral config.colorscheme.base03; + placeholder-color = mkLiteral config.theme.colors.base03; expand = true; horizontal-align = "0"; placeholder = "Launch Program"; @@ -85,7 +85,7 @@ # Results "#listview" = { - background-color = mkLiteral config.colorscheme.base00; + background-color = mkLiteral config.theme.colors.base00; padding = mkLiteral "0px"; columns = 1; lines = 12; @@ -104,9 +104,9 @@ "#element.selected" = { border = mkLiteral "1px"; border-radius = mkLiteral "4px"; - border-color = mkLiteral config.colorscheme.base07; - background-color = mkLiteral config.colorscheme.base04; - text-color = mkLiteral config.colorscheme.base00; + border-color = mkLiteral config.theme.colors.base07; + background-color = mkLiteral config.theme.colors.base04; + text-color = mkLiteral config.theme.colors.base00; }; "#element-text" = { @@ -116,8 +116,8 @@ margin = mkLiteral "0px 2.5px 0px 2.5px"; }; "#element-text.selected" = { - background-color = mkLiteral config.colorscheme.base04; - text-color = mkLiteral config.colorscheme.base00; + background-color = mkLiteral config.theme.colors.base04; + text-color = mkLiteral config.theme.colors.base00; }; # Not sure how to get icons @@ -125,11 +125,11 @@ size = mkLiteral "18px"; border = mkLiteral "0px"; padding = mkLiteral "2px 5px 2px 2px"; - background-color = mkLiteral config.colorscheme.base00; + background-color = mkLiteral config.theme.colors.base00; }; "#element-icon.selected" = { - background-color = mkLiteral config.colorscheme.base04; - text-color = mkLiteral config.colorscheme.base00; + background-color = mkLiteral config.theme.colors.base04; + text-color = mkLiteral config.theme.colors.base00; }; }; @@ -144,9 +144,9 @@ }; - gui.launcherCommand = "${pkgs.rofi}/bin/rofi -show run -modi run"; - gui.systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; - gui.altTabCommand = "${pkgs.rofi}/bin/rofi -show window -modi window"; + launcherCommand = "${pkgs.rofi}/bin/rofi -show run -modi run"; + systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; + altTabCommand = "${pkgs.rofi}/bin/rofi -show window -modi window"; }; diff --git a/modules/graphical/xorg.nix b/modules/graphical/xorg.nix index 353beab..868a299 100644 --- a/modules/graphical/xorg.nix +++ b/modules/graphical/xorg.nix @@ -1,15 +1,25 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, ... }: { -let - - gtkTheme = { - name = config.gui.gtk.theme.name; - package = pkgs.${config.gui.gtk.theme.package}; + options = { + gtk.theme = { + name = lib.mkOption { + type = lib.types.str; + description = "Theme name for GTK applications"; + }; + package = lib.mkOption { + type = lib.types.str; + description = "Theme package name for GTK applications"; + default = "gnome-themes-extra"; + }; + }; }; -in { - - config = lib.mkIf config.gui.enable { + config = let + gtkTheme = { + name = config.gtk.theme.name; + package = pkgs."${config.gtk.theme.package}"; + }; + in lib.mkIf config.gui.enable { # Enable the X11 windowing system. services.xserver = { @@ -22,7 +32,7 @@ in { displayManager = { lightdm = { enable = config.services.xserver.enable; - background = config.gui.wallpaper; + background = config.wallpaper; # Make the login screen dark greeters.gtk.theme = gtkTheme; @@ -46,7 +56,7 @@ in { services.dbus.packages = [ pkgs.dconf ]; programs.dconf.enable = true; - environment.sessionVariables = { GTK_THEME = config.gui.gtk.theme.name; }; + environment.sessionVariables = { GTK_THEME = config.gtk.theme.name; }; home-manager.users.${config.user} = { @@ -55,7 +65,10 @@ in { pbpaste = "xclip -selection clipboard -out"; }; - gtk = let gtkExtraConfig = { gtk-application-prefer-dark-theme = true; }; + gtk = let + gtkExtraConfig = { + gtk-application-prefer-dark-theme = config.theme.dark; + }; in { enable = true; theme = gtkTheme; diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index cbb51dd..a7cebcc 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -15,7 +15,12 @@ source = ./lua; recursive = true; # Allows adding more files }; - "nvim/lua/packer/colors.lua".source = config.colorscheme.neovimConfig; + "nvim/lua/packer/colors.lua".source = config.theme.colors.neovimConfig; + "nvim/lua/background.lua".text = '' + vim.cmd("set background=${ + if config.theme.dark == true then "dark" else "light" + }") + ''; }; programs.git.extraConfig.core.editor = "nvim"; diff --git a/modules/neovim/init.lua b/modules/neovim/init.lua index 8267993..d3d3ec6 100644 --- a/modules/neovim/init.lua +++ b/modules/neovim/init.lua @@ -1,3 +1,4 @@ require("packer_init") require("settings") require("keybinds") +require("background") From 07fec71ba4cb8a1bab656415265a009ac3d212d4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 2 Nov 2022 21:47:11 -0400 Subject: [PATCH 095/391] put hashed pass in a separate file --- .gitignore | 1 + hosts/desktop/default.nix | 3 +-- hosts/oracle/default.nix | 1 - hosts/wsl/default.nix | 3 +-- private/password.sha512 | 1 + 5 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 private/password.sha512 diff --git a/.gitignore b/.gitignore index 64113bc..fcaeac4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ result .luarc.json private/** !private/**.age +!private/**.sha512 diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index e351306..24d7ea9 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -22,8 +22,7 @@ nixpkgs.lib.nixosSystem { }; wallpaper = "${wallpapers}/gruvbox/road.jpg"; gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; } ./hardware-configuration.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 25fa460..c8a9163 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -28,7 +28,6 @@ nixpkgs.lib.nixosSystem { giteaServer = "git.masu.rs"; # Disable passwords, only use SSH key - passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index 2c700b4..1e9ec18 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -17,8 +17,7 @@ nixpkgs.lib.nixosSystem { identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = false; colorscheme = (import ../../modules/colorscheme/gruvbox); - passwordHash = - "$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF."; + passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; wsl = { enable = true; automountPath = "/mnt"; diff --git a/private/password.sha512 b/private/password.sha512 new file mode 100644 index 0000000..354b39e --- /dev/null +++ b/private/password.sha512 @@ -0,0 +1 @@ +$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF. From 77413943066e41688fc7a308aadb1293fe04abe4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 2 Nov 2022 22:15:29 -0400 Subject: [PATCH 096/391] add back removed applications --- hosts/desktop/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 24d7ea9..64a1b52 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -30,14 +30,16 @@ nixpkgs.lib.nixosSystem { ../../modules/hardware ../../modules/nixos ../../modules/graphical - ../../modules/gaming/steam.nix - ../../modules/gaming/legendary.nix ../../modules/applications/media.nix ../../modules/applications/firefox.nix ../../modules/applications/kitty.nix + ../../modules/applications/1password.nix ../../modules/applications/discord.nix ../../modules/applications/nautilus.nix + ../../modules/applications/obsidian.nix ../../modules/mail/default.nix + ../../modules/gaming/steam.nix + ../../modules/gaming/legendary.nix ../../modules/repositories/notes.nix ../../modules/services/keybase.nix ../../modules/services/mullvad.nix From 6241b8e624c21a3278cbdbf2c6d71069f0e590a9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 08:30:28 -0400 Subject: [PATCH 097/391] fix neovim tree-sitter bug requires installing tree-sitter and nodejs to environment :( --- modules/neovim/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index a7cebcc..8d48f02 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -5,6 +5,8 @@ home.packages = with pkgs; [ neovim gcc # for tree-sitter + tree-sitter # for tree-sitter-gitignore parser + nodejs # for tree-sitter-gitignore parser shfmt # used everywhere shellcheck # used everywhere ]; From 920ec8b43e088e55a66d46c22f48e8ff00eafa91 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 08:51:51 -0400 Subject: [PATCH 098/391] add terminfo to openssh devices --- modules/services/sshd.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/services/sshd.nix b/modules/services/sshd.nix index 094d624..099589e 100644 --- a/modules/services/sshd.nix +++ b/modules/services/sshd.nix @@ -28,6 +28,9 @@ # Implement a simple fail2ban service for sshd services.sshguard.enable = true; + + # Add terminfo for SSH from popular terminal emulators + environment.enableAllTerminfo = true; }; } From 9386008fa246f6a3f23d8c65dd0257da2d2577f7 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 11:24:03 -0400 Subject: [PATCH 099/391] fix: identity file wrong path on macos --- hosts/macbook/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 21132b9..654ad21 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -14,7 +14,7 @@ darwin.lib.darwinSystem { }) home-manager.darwinModules.home-manager { - identityFile = "/home/${globals.user}/.ssh/id_ed25519"; + identityFile = "/Users/Noah.Masur/.ssh/id_ed25519"; gui.enable = true; colorscheme = (import ../../modules/colorscheme/gruvbox); mailUser = globals.user; From 15f411617882c27020d5f637f408c332c7c956b7 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 11:25:36 -0400 Subject: [PATCH 100/391] fixes for kitty on macos --- modules/darwin/fonts.nix | 8 ++--- .../Spoons/MoveWindow.spoon/worklayout.lua | 35 ++++++++++--------- modules/darwin/system.nix | 4 ++- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/modules/darwin/fonts.nix b/modules/darwin/fonts.nix index 874457a..30925a9 100644 --- a/modules/darwin/fonts.nix +++ b/modules/darwin/fonts.nix @@ -3,15 +3,13 @@ home-manager.users.${config.user} = { home.packages = with pkgs; - [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ]; + [ (nerdfonts.override { fonts = [ "Victor Mono" ]; }) ]; - programs.alacritty.settings = { - font.normal.family = "FiraCode Nerd Font Mono"; - }; + programs.alacritty.settings = { font.normal.family = "Victor Mono"; }; programs.kitty.font = { package = pkgs.nerdfonts; - name = "FiraCode"; + name = "Victor Mono"; }; }; diff --git a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua index 7161ad9..ea5a46d 100644 --- a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua +++ b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua @@ -9,24 +9,25 @@ WORK_RIGHT_MONITOR = "DELL U2415 (1)" LAPTOP_MONITOR = "Built-in Retina Display" -- Used to find out the name of the monitor in Hammerspoon -function dump(o) - if type(o) == "table" then - local s = "{ " - for k, v in pairs(o) do - if type(k) ~= "number" then - k = '"' .. k .. '"' - end - s = s .. "[" .. k .. "] = " .. dump(v) .. "," - end - return s .. "} " - else - return tostring(o) - end -end +-- local function dump(o) +-- if type(o) == "table" then +-- local s = "{ " +-- for k, v in pairs(o) do +-- if type(k) ~= "number" then +-- k = '"' .. k .. '"' +-- end +-- s = s .. "[" .. k .. "] = " .. dump(v) .. "," +-- end +-- return s .. "} " +-- else +-- return tostring(o) +-- end +-- end + -- Turn on when looking for the monitor name -- print(dump(hs.screen.allScreens())) -function concat(...) +local function concat(...) local res = {} for _, tab in ipairs({ ... }) do for _, elem in ipairs(tab) do @@ -36,12 +37,12 @@ function concat(...) return res end -function worklayout() +local function worklayout() hs.hotkey.bind({ "alt", "ctrl", "cmd" }, "l", function() local u = hs.geometry.unitrect -- set the layout local left = { - -- { "Alacritty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, + { "kitty", nil, WORK_LEFT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, } local right = { { "Slack", nil, WORK_RIGHT_MONITOR, u(0, 0, 1, 1), nil, nil, visible = true }, diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 4c2eaa1..aae8eb8 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -1,7 +1,9 @@ -{ ... }: { +{ pkgs, ... }: { services.nix-daemon.enable = true; + environment.shells = [ pkgs.fish ]; + security.pam.enableSudoTouchIdAuth = true; system = { From 660ea997df59bc2d7bf54aaa2d89f57b19c05608 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 11:25:58 -0400 Subject: [PATCH 101/391] fix standalone home-manager on macos --- modules/darwin/nixpkgs.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index cde96ce..7330c27 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -21,7 +21,7 @@ rebuild-home = lib.mkForce { body = '' git -C ${config.dotfilesPath} add --intent-to-add --all - commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}"; + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#macbook"; commandline --function execute ''; }; From 7ae06494568c3c61425310e1b86fc25644db2d9c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 11:26:31 -0400 Subject: [PATCH 102/391] nixpkgs shortcut registries --- modules/shell/fish/functions/fish_user_key_bindings.fish | 4 ++-- modules/shell/nixpkgs.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/shell/fish/functions/fish_user_key_bindings.fish b/modules/shell/fish/functions/fish_user_key_bindings.fish index 04a2915..4c1e991 100644 --- a/modules/shell/fish/functions/fish_user_key_bindings.fish +++ b/modules/shell/fish/functions/fish_user_key_bindings.fish @@ -14,7 +14,7 @@ bind -M insert \cp projects bind -M default \cp projects bind -M insert \x1F accept-autosuggestion bind -M default \x1F accept-autosuggestion -bind -M insert \cn 'commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#"' -bind -M default \cn 'commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#"' +bind -M insert \cn 'commandline -r "nix run nixpkgs#"' +bind -M default \cn 'commandline -r "nix run nixpkgs#"' bind -M insert \x11F nix-fzf bind -M default \x11F nix-fzf diff --git a/modules/shell/nixpkgs.nix b/modules/shell/nixpkgs.nix index e6a1840..0a8358c 100644 --- a/modules/shell/nixpkgs.nix +++ b/modules/shell/nixpkgs.nix @@ -19,9 +19,9 @@ body = '' set program $argv[1] if test (count $argv) -ge 2 - commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#$program -- $argv[2..-1]" + commandline -r "nix run nixpkgs#$program -- $argv[2..-1]" else - commandline -r "nix run github:NixOS/nixpkgs/nixpkgs-unstable#$program" + commandline -r "nix run nixpkgs#$program" end commandline -f execute ''; From 4ea56b0aab09cb76018a5b203fa732e8acdebad0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 3 Nov 2022 21:20:29 -0400 Subject: [PATCH 103/391] fix: remove bell sounds from kitty --- modules/applications/kitty.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index 82e4cf7..dd4d727 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -69,6 +69,9 @@ tab_bar_edge = "top"; tab_bar_style = "slant"; + + # Audio + enable_audio_bell = false; }; }; }; From c871f59791ecfdcb8c31a48196b46834c802e690 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 5 Nov 2022 13:41:09 -0400 Subject: [PATCH 104/391] fixes for light mode --- hosts/desktop/default.nix | 4 +- modules/applications/firefox.nix | 2 + modules/colorscheme/gruvbox/default.nix | 4 +- modules/colorscheme/gruvbox/neovim.lua | 1 - modules/neovim/default.nix | 4 +- modules/shell/utilities.nix | 85 ++++++++++++++----------- 6 files changed, 56 insertions(+), 44 deletions(-) diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 64a1b52..022539a 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -17,8 +17,8 @@ nixpkgs.lib.nixosSystem { identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = true; theme = { - colors = (import ../../modules/colorscheme/gruvbox).dark; - dark = true; + colors = (import ../../modules/colorscheme/gruvbox).light; + dark = false; }; wallpaper = "${wallpapers}/gruvbox/road.jpg"; gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 723d8d6..6ef36ab 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -45,6 +45,8 @@ "toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Allow userChrome.css "layout.css.color-mix.enabled" = true; + "ui.systemUsesDarkTheme" = + if config.theme.dark == true then 1 else 0; }; userChrome = '' :root { diff --git a/modules/colorscheme/gruvbox/default.nix b/modules/colorscheme/gruvbox/default.nix index 3567f00..07441ed 100644 --- a/modules/colorscheme/gruvbox/default.nix +++ b/modules/colorscheme/gruvbox/default.nix @@ -20,6 +20,7 @@ base0E = "#d3869b"; # purple base0F = "#d65d0e"; # brown neovimConfig = ./neovim.lua; + batTheme = "gruvbox-dark"; }; light = { base00 = "#fbf1c7"; # ---- @@ -38,6 +39,7 @@ base0D = "#076678"; # blue base0E = "#8f3f71"; # purple base0F = "#d65d0e"; # brown - neovimConfig = ./neovim-light.lua; + neovimConfig = ./neovim.lua; + batTheme = "gruvbox-light"; }; } diff --git a/modules/colorscheme/gruvbox/neovim.lua b/modules/colorscheme/gruvbox/neovim.lua index db3f77c..086b0cb 100644 --- a/modules/colorscheme/gruvbox/neovim.lua +++ b/modules/colorscheme/gruvbox/neovim.lua @@ -6,7 +6,6 @@ M.packer = function(use) config = function() vim.g.gruvbox_italicize_strings = 0 vim.cmd("colorscheme gruvbox8") - vim.cmd("set background=dark") end, }) end diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index 8d48f02..a52b63e 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -19,9 +19,9 @@ }; "nvim/lua/packer/colors.lua".source = config.theme.colors.neovimConfig; "nvim/lua/background.lua".text = '' - vim.cmd("set background=${ + vim.o.background = "${ if config.theme.dark == true then "dark" else "light" - }") + }" ''; }; diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index 33d9c49..c32d6d2 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -13,50 +13,59 @@ let in { - home-manager.users.${config.user} = { + config = { - home.packages = with pkgs; [ - unzip # Extract zips - rsync # Copy folders - ripgrep # grep - bat # cat - fd # find - sd # sed - jq # JSON manipulation - tealdeer # Cheatsheets - tree # View directory hierarchy - htop # Show system processes - glow # Pretty markdown previews - qrencode # Generate qr codes - vimv-rs # Batch rename files - dig # DNS lookup - lf # File viewer - # whois # Lookup IPs - age # Encryption - ]; + home-manager.users.${config.user} = { - programs.zoxide.enable = true; # Shortcut jump command + home.packages = with pkgs; [ + unzip # Extract zips + rsync # Copy folders + ripgrep # grep + fd # find + sd # sed + jq # JSON manipulation + tealdeer # Cheatsheets + tree # View directory hierarchy + htop # Show system processes + glow # Pretty markdown previews + qrencode # Generate qr codes + vimv-rs # Batch rename files + dig # DNS lookup + lf # File viewer + inetutils # Includes telnet, whois + age # Encryption + ]; - home.file = { - ".rgignore".text = ignorePatterns; - ".fdignore".text = ignorePatterns; - ".digrc".text = "+noall +answer"; # Cleaner dig commands - }; + programs.zoxide.enable = true; # Shortcut jump command - programs.fish.shellAbbrs = { - cat = "bat"; # Swap cat with bat - }; - - programs.fish.functions = { - ping = { - description = "Improved ping"; - argumentNames = "target"; - body = "${pkgs.prettyping}/bin/prettyping --nolegend $target"; + home.file = { + ".rgignore".text = ignorePatterns; + ".fdignore".text = ignorePatterns; + ".digrc".text = "+noall +answer"; # Cleaner dig commands }; - qr = { - body = - "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | open /tmp/qr.png"; # Fix for non-macOS + + programs.bat = { + enable = true; # cat replacement + config = { theme = config.theme.colors.batTheme; }; }; + + programs.fish.shellAbbrs = { + cat = "bat"; # Swap cat with bat + }; + + programs.fish.functions = { + ping = { + description = "Improved ping"; + argumentNames = "target"; + body = "${pkgs.prettyping}/bin/prettyping --nolegend $target"; + }; + qr = { + # Fix for non-macOS + body = + "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png"; + }; + }; + }; }; From 5bbba2be396dd639587a87883f4a52ca12ac1668 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 5 Nov 2022 19:38:43 -0400 Subject: [PATCH 105/391] set back to dark mode default --- hosts/desktop/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 022539a..64a1b52 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -17,8 +17,8 @@ nixpkgs.lib.nixosSystem { identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = true; theme = { - colors = (import ../../modules/colorscheme/gruvbox).light; - dark = false; + colors = (import ../../modules/colorscheme/gruvbox).dark; + dark = true; }; wallpaper = "${wallpapers}/gruvbox/road.jpg"; gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; From b04c442c874ab07c5c5f75f25a12898dddfc3dfe Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 7 Nov 2022 08:04:29 -0500 Subject: [PATCH 106/391] replace rnix lsp with nil --- modules/neovim/lua/packer/lsp.lua | 4 ++-- modules/programming/nix.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/neovim/lua/packer/lsp.lua b/modules/neovim/lua/packer/lsp.lua index 1a4ccc2..82dd205 100644 --- a/modules/neovim/lua/packer/lsp.lua +++ b/modules/neovim/lua/packer/lsp.lua @@ -46,8 +46,8 @@ M.packer = function(use) capabilities = capabilities, }) end - if on_path("rnix-lsp") then - require("lspconfig").rnix.setup({ capabilities = capabilities }) + if on_path("nil") then + require("lspconfig").nil_ls.setup({ capabilities = capabilities }) end vim.keymap.set("n", "gd", vim.lsp.buf.definition) diff --git a/modules/programming/nix.nix b/modules/programming/nix.nix index f928118..272b227 100644 --- a/modules/programming/nix.nix +++ b/modules/programming/nix.nix @@ -4,7 +4,7 @@ home.packages = with pkgs; [ nixfmt # Nix file formatter - rnix-lsp # Nix language server + nil # Nix language server ]; }; From 2340b862e52b35ae539585cb47ceb15df4a323b6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 7 Nov 2022 20:54:01 -0500 Subject: [PATCH 107/391] add noisetorch for mic noise suppression --- modules/applications/discord.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/applications/discord.nix b/modules/applications/discord.nix index 91d7783..0d30622 100644 --- a/modules/applications/discord.nix +++ b/modules/applications/discord.nix @@ -15,5 +15,6 @@ } ''; }; + programs.noisetorch.enable = true; }; } From 8342746b693e79e126d4c05b54bb5f66285d759c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 10 Nov 2022 04:26:38 +0000 Subject: [PATCH 108/391] fix wsl with new theme --- hosts/desktop/default.nix | 2 +- hosts/wsl/default.nix | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 64a1b52..89d134c 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -37,7 +37,7 @@ nixpkgs.lib.nixosSystem { ../../modules/applications/discord.nix ../../modules/applications/nautilus.nix ../../modules/applications/obsidian.nix - ../../modules/mail/default.nix + ../../modules/mail ../../modules/gaming/steam.nix ../../modules/gaming/legendary.nix ../../modules/repositories/notes.nix diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index 1e9ec18..3c428c4 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -16,7 +16,10 @@ nixpkgs.lib.nixosSystem { nix.registry.nixpkgs.flake = nixpkgs; identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = false; - colorscheme = (import ../../modules/colorscheme/gruvbox); + theme = { + colors = (import ../../modules/colorscheme/gruvbox).dark; + dark = true; + }; passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; wsl = { enable = true; @@ -31,7 +34,7 @@ nixpkgs.lib.nixosSystem { ../common.nix ../../modules/wsl ../../modules/nixos - ../../modules/mail/himalaya.nix + ../../modules/mail ../../modules/repositories/notes.nix ../../modules/programming/nix.nix ../../modules/programming/lua.nix From 0176b14350931dce20a1cf64f586991681bbd945 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 14 Nov 2022 10:35:16 -0500 Subject: [PATCH 109/391] move qr to nautilusg --- modules/applications/nautilus.nix | 7 +++++++ modules/shell/utilities.nix | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/applications/nautilus.nix b/modules/applications/nautilus.nix index 28cfb3a..7406a4c 100644 --- a/modules/applications/nautilus.nix +++ b/modules/applications/nautilus.nix @@ -7,6 +7,13 @@ gnome.nautilus gnome.sushi # Quick preview with spacebar ]; + + programs.fish.functions = { + qr = { + body = + "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png"; + }; + }; }; }; diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index c32d6d2..30d6741 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -59,11 +59,6 @@ in { argumentNames = "target"; body = "${pkgs.prettyping}/bin/prettyping --nolegend $target"; }; - qr = { - # Fix for non-macOS - body = - "${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png"; - }; }; }; From 2ab37d3298299f93cf22c3ebb9e3c643f3b0446c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 14 Nov 2022 10:35:36 -0500 Subject: [PATCH 110/391] move noisetorch to linux audio --- modules/applications/discord.nix | 1 - modules/hardware/audio.nix | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/applications/discord.nix b/modules/applications/discord.nix index 0d30622..91d7783 100644 --- a/modules/applications/discord.nix +++ b/modules/applications/discord.nix @@ -15,6 +15,5 @@ } ''; }; - programs.noisetorch.enable = true; }; } diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 3007b6f..6d0f234 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -39,6 +39,9 @@ in { pulse.enable = true; }; + # Provides audio source with background noise filtered + programs.noisetorch.enable = true; + # These aren't necessary, but helpful for the user environment.systemPackages = with pkgs; [ pamixer # Audio control From 5178c9f458d065c32b798c9a461a923438f9c857 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:52:00 -0500 Subject: [PATCH 111/391] fix colorscheme for macbook --- hosts/macbook/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 654ad21..ed6c624 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -16,7 +16,10 @@ darwin.lib.darwinSystem { { identityFile = "/Users/Noah.Masur/.ssh/id_ed25519"; gui.enable = true; - colorscheme = (import ../../modules/colorscheme/gruvbox); + theme = { + colors = (import ../../modules/colorscheme/gruvbox).dark; + dark = true; + }; mailUser = globals.user; networking.hostName = "noah-masur-mac"; nixpkgs.overlays = [ nur.overlay ]; From 07b5f855a613d91b8b0335635375763b7d5f6b2e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 16 Nov 2022 15:52:24 -0500 Subject: [PATCH 112/391] disable firefox autofill --- modules/applications/firefox.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 6ef36ab..570e890 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -38,6 +38,7 @@ "browser.toolbars.bookmarks.visibility" = "newtab"; "browser.startup.page" = 3; # Restore previous session "browser.newtabpage.enabled" = false; # Make new tabs blank + "dom.forms.autocomplete.formautofill" = false; # Disable autofill "general.autoScroll" = true; # Drag middle-mouse to scroll "services.sync.prefs.sync.general.autoScroll" = false; # Prevent disabling autoscroll From e1fc3317b54d3fae1feae97e677b1f7da641211a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 18 Nov 2022 22:35:00 -0500 Subject: [PATCH 113/391] adjust aws package layout --- flake.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index d588a57..76be6fb 100644 --- a/flake.nix +++ b/flake.nix @@ -83,12 +83,10 @@ }; # Package servers into images with a generator - packages.x86_64-linux = with inputs; { - aws = import ./hosts/aws { - inherit inputs globals; - system = "x86_64-linux"; - }; - }; + packages.aws = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] + (system: { + "${system}" = import ./hosts/aws { inherit inputs globals system; }; + }); apps = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; From 30f9f869a78d4b4c463fce728a8deada1ee9d8c3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 19 Nov 2022 19:11:26 -0700 Subject: [PATCH 114/391] force fish shell for kitty --- modules/darwin/kitty.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix index 5191927..85e18e3 100644 --- a/modules/darwin/kitty.nix +++ b/modules/darwin/kitty.nix @@ -6,7 +6,7 @@ darwinLaunchOptions = [ "--start-as=fullscreen" ]; font.size = lib.mkForce 20; settings = { - shell = "${pkgs.fish}/bin/fish"; + shell = "/run/current-system/sw/bin/fish"; macos_traditional_fullscreen = true; macos_quit_when_last_window_closed = true; }; From d1f12671b04e16313739d850f1b969a5f025f16a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 19 Nov 2022 19:12:01 -0700 Subject: [PATCH 115/391] force neovim fish shell in toggleterm --- modules/neovim/lua/packer/toggleterm.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/neovim/lua/packer/toggleterm.lua b/modules/neovim/lua/packer/toggleterm.lua index 88da4e7..575e652 100644 --- a/modules/neovim/lua/packer/toggleterm.lua +++ b/modules/neovim/lua/packer/toggleterm.lua @@ -9,6 +9,7 @@ M.packer = function(use) open_mapping = [[]], hide_numbers = true, direction = "float", + shell = "fish", -- Force fish for everything }) vim.keymap.set("t", "", "") --- Exit terminal mode From a6f9b985fc072e6a0fa2950bfd29612deb9ed83b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 19 Nov 2022 19:12:04 -0700 Subject: [PATCH 116/391] Revert "force neovim fish shell in toggleterm" This reverts commit d1f12671b04e16313739d850f1b969a5f025f16a. --- modules/neovim/lua/packer/toggleterm.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/neovim/lua/packer/toggleterm.lua b/modules/neovim/lua/packer/toggleterm.lua index 575e652..88da4e7 100644 --- a/modules/neovim/lua/packer/toggleterm.lua +++ b/modules/neovim/lua/packer/toggleterm.lua @@ -9,7 +9,6 @@ M.packer = function(use) open_mapping = [[]], hide_numbers = true, direction = "float", - shell = "fish", -- Force fish for everything }) vim.keymap.set("t", "", "") --- Exit terminal mode From 2848ae94240b3e9f38b3e63e6f99d4c908a77f5b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 19 Nov 2022 19:40:04 -0700 Subject: [PATCH 117/391] switch kitty to victormono font --- modules/darwin/fonts.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/darwin/fonts.nix b/modules/darwin/fonts.nix index 30925a9..09892c1 100644 --- a/modules/darwin/fonts.nix +++ b/modules/darwin/fonts.nix @@ -3,13 +3,13 @@ home-manager.users.${config.user} = { home.packages = with pkgs; - [ (nerdfonts.override { fonts = [ "Victor Mono" ]; }) ]; + [ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ]; - programs.alacritty.settings = { font.normal.family = "Victor Mono"; }; + programs.alacritty.settings = { font.normal.family = "VictorMono"; }; programs.kitty.font = { - package = pkgs.nerdfonts; - name = "Victor Mono"; + package = (pkgs.nerdfonts.override { fonts = [ "VictorMono" ]; }); + name = "VictorMono Nerd Font Mono"; }; }; From 42237eab13464df361fb3ced8fd61d3e1698bffe Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 20 Nov 2022 11:38:10 -0700 Subject: [PATCH 118/391] fix: aerc doesn't recognize config file --- modules/darwin/user.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/darwin/user.nix b/modules/darwin/user.nix index d3bfbc0..a5dc1cb 100644 --- a/modules/darwin/user.nix +++ b/modules/darwin/user.nix @@ -4,6 +4,12 @@ # macOS user home = config.homePath; shell = pkgs.fish; # Default shell + + }; + + # Used for aerc + home-manager.users.${config.user} = { + home.sessionVariables = { XDG_CONFIG_HOME = "${config.homePath}/.config"; }; }; } From 44c4084b57cecffa49f8af53b4dcd1dd7d83d227 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 20 Nov 2022 11:51:46 -0700 Subject: [PATCH 119/391] fix: tfvars recognized as terraform --- modules/neovim/lua/settings.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index ef2cec6..b54e05a 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -75,6 +75,11 @@ vim.api.nvim_exec( false ) +vim.filetype.add({ + pattern = { + [".*%.tfvars"] = "terraform", + }, +}) vim.api.nvim_create_autocmd("FileType", { pattern = "*.eml", callback = function() From 3beacf9f3cf54693a259285d1022f08c6621f47a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 20 Nov 2022 11:52:33 -0700 Subject: [PATCH 120/391] adjust k9s toggleterm keybind --- modules/neovim/lua/packer/toggleterm.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/neovim/lua/packer/toggleterm.lua b/modules/neovim/lua/packer/toggleterm.lua index 88da4e7..a185e94 100644 --- a/modules/neovim/lua/packer/toggleterm.lua +++ b/modules/neovim/lua/packer/toggleterm.lua @@ -50,7 +50,7 @@ M.packer = function(use) vim.keymap.set("n", "t", TERM_TOGGLE) vim.keymap.set("n", "P", NIXPKGS_TOGGLE) vim.keymap.set("n", "gw", GITWATCH_TOGGLE) - vim.keymap.set("n", "", K9S_TOGGLE) + vim.keymap.set("n", "9", K9S_TOGGLE) end, }) From f304392d58c6b043a35016094f65d60d88c5b343 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 20 Nov 2022 11:55:11 -0700 Subject: [PATCH 121/391] fix: victormono italic glitch on macos --- modules/darwin/kitty.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix index 85e18e3..2e1121a 100644 --- a/modules/darwin/kitty.nix +++ b/modules/darwin/kitty.nix @@ -9,6 +9,7 @@ shell = "/run/current-system/sw/bin/fish"; macos_traditional_fullscreen = true; macos_quit_when_last_window_closed = true; + disable_ligatures = "always"; }; }; }; From b9ddaf095c200810393d54f0a7e5c7bf7d4c3978 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 20 Nov 2022 12:09:03 -0700 Subject: [PATCH 122/391] replace alacritty with kitty in macos dock --- modules/darwin/system.nix | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index aae8eb8..853d022 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -132,6 +132,16 @@ defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 + echo "Allow apps from anywhere" + SPCTL=$(spctl --status) + if ! [ "$SPCTL" = "assessments disabled" ]; then + sudo spctl --master-disable + fi + + ''; + + # User-level settings + activationScripts.postUserActivation.text = '' echo "Show the ~/Library folder" chflags nohidden ~/Library @@ -162,16 +172,10 @@ "$(__dock_item /Applications/Mimestream.app)" \ "$(__dock_item /Applications/zoom.us.app)" \ "$(__dock_item /Applications/Obsidian.app)" \ - "$(__dock_item /Applications/Alacritty.app)" \ + "$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \ "$(__dock_item /System/Applications/System\ Preferences.app)" - - echo "Allow apps from anywhere" - SPCTL=$(spctl --status) - if ! [ "$SPCTL" = "assessments disabled" ]; then - sudo spctl --master-disable - fi - ''; + }; } From 7ddd9d9aa4fe1516d815a1b265f0a33b9fef1c2e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 20 Nov 2022 12:12:18 -0700 Subject: [PATCH 123/391] add discord to macos dock --- modules/darwin/system.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 853d022..ff474a2 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -171,6 +171,7 @@ "$(__dock_item /System/Applications/Mail.app)" \ "$(__dock_item /Applications/Mimestream.app)" \ "$(__dock_item /Applications/zoom.us.app)" \ + "$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \ "$(__dock_item /Applications/Obsidian.app)" \ "$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \ "$(__dock_item /System/Applications/System\ Preferences.app)" From 52f9057ee59601193d9424d981fd353d1cc4b57c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 21 Nov 2022 01:04:22 +0000 Subject: [PATCH 124/391] unused n8n setup --- modules/services/n8n.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 modules/services/n8n.nix diff --git a/modules/services/n8n.nix b/modules/services/n8n.nix new file mode 100644 index 0000000..fe0c5ea --- /dev/null +++ b/modules/services/n8n.nix @@ -0,0 +1,21 @@ +{ ... }: { + + services.n8n = { + enable = true; + settings = { + n8n = { + listenAddress = "127.0.0.1"; + port = 5678; + }; + }; + }; + + caddyRoutes = [{ + match = [{ host = [ config.n8nServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:5678"; }]; + }]; + }]; + +} From d672a77ddb65eb8c06e191ba046eee66efdb60e5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 23 Nov 2022 14:37:57 -0700 Subject: [PATCH 125/391] fix alt-e in fish for kitty --- modules/darwin/kitty.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix index 2e1121a..7fb840a 100644 --- a/modules/darwin/kitty.nix +++ b/modules/darwin/kitty.nix @@ -10,6 +10,7 @@ macos_traditional_fullscreen = true; macos_quit_when_last_window_closed = true; disable_ligatures = "always"; + macos_option_as_alt = true; }; }; }; From 97ed5eb33b72902e94a5548cf866e9e24a627697 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 23 Nov 2022 15:46:30 -0700 Subject: [PATCH 126/391] switch from homebrew to firefox overlay for macos --- flake.lock | 41 +++++++++++++++++++++++++++++--- flake.nix | 3 +++ hosts/macbook/default.nix | 3 ++- modules/applications/firefox.nix | 1 + modules/darwin/homebrew.nix | 1 - modules/darwin/system.nix | 2 +- 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 5a442fc..6de5404 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,24 @@ "type": "github" } }, + "firefox-darwin": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1668992358, + "narHash": "sha256-24iH+wIbE1bKCFmqslwOpfrDypJ40mk1uGIqRUxDXxY=", + "owner": "bandithedoge", + "repo": "nixpkgs-firefox-darwin", + "rev": "066d4fd658acd075b45405eda9e3bca6a71a47b1", + "type": "github" + }, + "original": { + "owner": "bandithedoge", + "repo": "nixpkgs-firefox-darwin", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -111,6 +129,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1639237670, + "narHash": "sha256-RTdL4rEQcgaZGpvtDgkp3oK/V+1LM3I53n0ACPSroAQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "edfb969386ebe6c3cf8f878775a7975cd88f926d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1666959691, "narHash": "sha256-TRpWA3t8ata79HOGtFd5dDCl1kJQmIE16PDF53/Hcxo=", @@ -126,7 +160,7 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { "lastModified": 1660318005, "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=", @@ -159,9 +193,10 @@ "root": { "inputs": { "darwin": "darwin", + "firefox-darwin": "firefox-darwin", "home-manager": "home-manager", "nixos-generators": "nixos-generators", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nur": "nur", "wallpapers": "wallpapers", "wsl": "wsl" @@ -202,7 +237,7 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1666720338, diff --git a/flake.nix b/flake.nix index 76be6fb..f8aa770 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,9 @@ # Community packages; used for Firefox extensions nur.url = "github:nix-community/nur"; + # Use official Firefox binary for macOS + firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin"; + # Wallpapers wallpapers = { url = "gitlab:exorcist365/wallpapers"; diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index ed6c624..74e2f90 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -22,7 +22,7 @@ darwin.lib.darwinSystem { }; mailUser = globals.user; networking.hostName = "noah-masur-mac"; - nixpkgs.overlays = [ nur.overlay ]; + nixpkgs.overlays = [ nur.overlay firefox-darwin.overlay ]; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; } @@ -32,6 +32,7 @@ darwin.lib.darwinSystem { ../../modules/applications/alacritty.nix ../../modules/applications/kitty.nix ../../modules/applications/discord.nix + ../../modules/applications/firefox.nix ../../modules/repositories/notes.nix ../../modules/programming/nix.nix ../../modules/programming/terraform.nix diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 570e890..3b1a246 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -9,6 +9,7 @@ programs.firefox = { enable = true; + package = lib.mkIf pkgs.stdenv.isDarwin pkgs.firefox-bin; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ ublock-origin vimium diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index b6ffb64..317cd27 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -32,7 +32,6 @@ "openjdk" # Required by Apache Directory Studio ]; casks = [ - "firefox" # Firefox packaging on Nix is broken for macOS "1password" # 1Password packaging on Nix is broken for macOS "scroll-reverser" # Different scroll style for mouse vs. trackpad "meetingbar" # Show meetings in menu bar diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index ff474a2..0294446 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -166,7 +166,7 @@ "$(__dock_item /Applications/1Password.app)" \ "$(__dock_item /Applications/Slack.app)" \ "$(__dock_item /System/Applications/Calendar.app)" \ - "$(__dock_item /Applications/Firefox.app)" \ + "$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \ "$(__dock_item /System/Applications/Messages.app)" \ "$(__dock_item /System/Applications/Mail.app)" \ "$(__dock_item /Applications/Mimestream.app)" \ From cf62184744638413aa3b715ab8212eaf01009687 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 12:29:45 -0700 Subject: [PATCH 127/391] first neovim build package --- flake.lock | 445 ++++++++++++++++++++++++++++- flake.nix | 106 ++++++- modules/neovim/plugins-overlay.nix | 53 ++++ 3 files changed, 597 insertions(+), 7 deletions(-) create mode 100644 modules/neovim/plugins-overlay.nix diff --git a/flake.lock b/flake.lock index 6de5404..d671881 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,69 @@ { "nodes": { + "Comment-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1668781964, + "narHash": "sha256-po1MyuuOH3e8yJTAtkxnusFSJuNpQnjpe+zfWPoO62E=", + "owner": "numToStr", + "repo": "Comment.nvim", + "rev": "5f01c1a89adafc52bf34e3bf690f80d9d726715d", + "type": "github" + }, + "original": { + "owner": "numToStr", + "repo": "Comment.nvim", + "type": "github" + } + }, + "bufferline-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1668632062, + "narHash": "sha256-qGl1jwBaMFWsrth7F20KrfJpyVENF8GEOJsVBBcSTVA=", + "owner": "akinsho", + "repo": "bufferline.nvim", + "rev": "4ecfa81e470a589e74adcde3d5bb1727dd407363", + "type": "github" + }, + "original": { + "owner": "akinsho", + "repo": "bufferline.nvim", + "type": "github" + } + }, + "cmp-buffer-src": { + "flake": false, + "locked": { + "lastModified": 1660101488, + "narHash": "sha256-dG4U7MtnXThoa/PD+qFtCt76MQ14V1wX8GMYcvxEnbM=", + "owner": "hrsh7th", + "repo": "cmp-buffer", + "rev": "3022dbc9166796b644a841a02de8dd1cc1d311fa", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-buffer", + "type": "github" + } + }, + "cmp-nvim-lsp-src": { + "flake": false, + "locked": { + "lastModified": 1668566979, + "narHash": "sha256-Mqkp8IH/laUx0cK7S0BjusTT+OtOOJOamZM4+93RHdU=", + "owner": "hrsh7th", + "repo": "cmp-nvim-lsp", + "rev": "59224771f91b86d1de12570b4070fe4ad7cd1eeb", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-nvim-lsp", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -56,6 +120,21 @@ } }, "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -70,6 +149,37 @@ "type": "github" } }, + "flake-utils_3": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitsigns-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1668016276, + "narHash": "sha256-u8nHB4QwP1hkfI64MGF5luTof88hTdpF5s1KBr3X2jE=", + "owner": "lewis6991", + "repo": "gitsigns.nvim", + "rev": "9ff7dfb051e5104088ff80556203634fc8f8546d", + "type": "github" + }, + "original": { + "owner": "lewis6991", + "repo": "gitsigns.nvim", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -92,6 +202,79 @@ "type": "github" } }, + "impatient-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1668271823, + "narHash": "sha256-tsdTHbUC0kYOGonJ1TLIsHnv/RgWGTqHKY3xVj80mxM=", + "owner": "lewis6991", + "repo": "impatient.nvim", + "rev": "d3dd30ff0b811756e735eb9020609fa315bfbbcc", + "type": "github" + }, + "original": { + "owner": "lewis6991", + "repo": "impatient.nvim", + "type": "github" + } + }, + "lualine-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1669435324, + "narHash": "sha256-nbvFpC6/QEIwbnw1Zy4mEutpfI/lFKfPeTXUJmRIODc=", + "owner": "hoob3rt", + "repo": "lualine.nvim", + "rev": "b6314ac556098d7abea9bb8cf896d2e3500eca41", + "type": "github" + }, + "original": { + "owner": "hoob3rt", + "repo": "lualine.nvim", + "type": "github" + } + }, + "nil": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1669391194, + "narHash": "sha256-4oWcXqyBYPHF+Wt8AxRhWk70O1qVJPkyBw2IhxJtj6k=", + "owner": "oxalica", + "repo": "nil", + "rev": "afec5fed829ee193de7e8c62e1fb4bd55140f4ac", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "nil", + "type": "github" + } + }, + "nix2vim": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1666021730, + "narHash": "sha256-eXd9bqYleh+BZsUybKCj7rNhnwoV0tzsuGGXKmW/+NA=", + "owner": "gytis-ivaskevicius", + "repo": "nix2vim", + "rev": "f3b56da72278cd720fe7fb4b6d001047b7179669", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "nix2vim", + "type": "github" + } + }, "nixlib": { "locked": { "lastModified": 1636849918, @@ -145,6 +328,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1669165918, + "narHash": "sha256-hIVruk2+0wmw/Kfzy11rG3q7ev3VTi/IKVODeHcVjFo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3b400a525d92e4085e46141ff48cbf89fd89739e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1666959691, "narHash": "sha256-TRpWA3t8ata79HOGtFd5dDCl1kJQmIE16PDF53/Hcxo=", @@ -160,7 +359,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1660318005, "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=", @@ -175,6 +374,22 @@ "type": "indirect" } }, + "null-ls-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1669235424, + "narHash": "sha256-po66LOeGuBHi3MZsn5+/gYdgU+oFTZUPfPWx2norc3I=", + "owner": "jose-elias-alvarez", + "repo": "null-ls.nvim", + "rev": "c51978f546a86a653f4a492b86313f4616412cec", + "type": "github" + }, + "original": { + "owner": "jose-elias-alvarez", + "repo": "null-ls.nvim", + "type": "github" + } + }, "nur": { "locked": { "lastModified": 1667025500, @@ -190,18 +405,192 @@ "type": "github" } }, + "nvim-lspconfig-src": { + "flake": false, + "locked": { + "lastModified": 1669447443, + "narHash": "sha256-ikrkXhzkn4nYqJd9WaG61UGYWRdY2cbzKQIR+kDcYqE=", + "owner": "neovim", + "repo": "nvim-lspconfig", + "rev": "abe6c99c7489de2c317869cf5dea57a9595a0cca", + "type": "github" + }, + "original": { + "owner": "neovim", + "repo": "nvim-lspconfig", + "type": "github" + } + }, + "nvim-tree-lua-src": { + "flake": false, + "locked": { + "lastModified": 1669432749, + "narHash": "sha256-YQix8eYrruuyH5pzjFvxb6hbMLhu1X/hnymO9dmbCqs=", + "owner": "kyazdani42", + "repo": "nvim-tree.lua", + "rev": "b17358ff4d822deeb42b97919065800f8f91cb55", + "type": "github" + }, + "original": { + "owner": "kyazdani42", + "repo": "nvim-tree.lua", + "type": "github" + } + }, + "nvim-treesitter-src": { + "flake": false, + "locked": { + "lastModified": 1669484329, + "narHash": "sha256-aAzVCRoqa2TDMsDKuxFRJHleR4ubA0bLaCVYk96/su8=", + "owner": "nvim-treesitter", + "repo": "nvim-treesitter", + "rev": "5aacb06135a952190933f9bfff923957db8965db", + "type": "github" + }, + "original": { + "owner": "nvim-treesitter", + "repo": "nvim-treesitter", + "type": "github" + } + }, + "nvim-web-devicons-src": { + "flake": false, + "locked": { + "lastModified": 1669423115, + "narHash": "sha256-Wyd4HnV+aQrh4Z2KdwCdi84glzIbQt8/y7NRGf67hcw=", + "owner": "kyazdani42", + "repo": "nvim-web-devicons", + "rev": "189ad3790d57c548896a78522fd8b0d0fc11be31", + "type": "github" + }, + "original": { + "owner": "kyazdani42", + "repo": "nvim-web-devicons", + "type": "github" + } + }, + "plenary-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1664607953, + "narHash": "sha256-lIdBrVpi+vUudeotjFAuw4C0VT8TPoFE9cVVAQEsAYU=", + "owner": "nvim-lua", + "repo": "plenary.nvim", + "rev": "4b7e52044bbb84242158d977a50c4cbcd85070c7", + "type": "github" + }, + "original": { + "owner": "nvim-lua", + "repo": "plenary.nvim", + "type": "github" + } + }, "root": { "inputs": { + "Comment-nvim-src": "Comment-nvim-src", + "bufferline-nvim-src": "bufferline-nvim-src", + "cmp-buffer-src": "cmp-buffer-src", + "cmp-nvim-lsp-src": "cmp-nvim-lsp-src", "darwin": "darwin", "firefox-darwin": "firefox-darwin", + "gitsigns-nvim-src": "gitsigns-nvim-src", "home-manager": "home-manager", + "impatient-nvim-src": "impatient-nvim-src", + "lualine-nvim-src": "lualine-nvim-src", + "nil": "nil", + "nix2vim": "nix2vim", "nixos-generators": "nixos-generators", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", + "null-ls-nvim-src": "null-ls-nvim-src", "nur": "nur", + "nvim-lspconfig-src": "nvim-lspconfig-src", + "nvim-tree-lua-src": "nvim-tree-lua-src", + "nvim-treesitter-src": "nvim-treesitter-src", + "nvim-web-devicons-src": "nvim-web-devicons-src", + "plenary-nvim-src": "plenary-nvim-src", + "telescope-nvim-src": "telescope-nvim-src", + "telescope-project-nvim-src": "telescope-project-nvim-src", + "toggleterm-nvim-src": "toggleterm-nvim-src", + "vim-bbye-src": "vim-bbye-src", + "vim-repeat-src": "vim-repeat-src", + "vim-surround-src": "vim-surround-src", "wallpapers": "wallpapers", "wsl": "wsl" } }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "nil", + "flake-utils" + ], + "nixpkgs": [ + "nil", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669170936, + "narHash": "sha256-TKPH4Pzkjw5gAPo9hejs3O4mWJW6V/RSiOj8UuSFRTs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c90c223c4aef334356029b89c72bb65e26f7efe6", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "telescope-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1669224375, + "narHash": "sha256-NqMtFHgYO031WLDHb7AuVRUFMA72LHYVjbD0bt26O6I=", + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "rev": "cea9c75c19d172d2c6f089f21656019734a615cf", + "type": "github" + }, + "original": { + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "type": "github" + } + }, + "telescope-project-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1665406281, + "narHash": "sha256-ZBFgUlW+h7vndazZ0lZux8i7yQHKJNDPQPZ2z96Rfpk=", + "owner": "nvim-telescope", + "repo": "telescope-project.nvim", + "rev": "ff4d3cea905383a67d1a47b9dd210c4907d858c2", + "type": "github" + }, + "original": { + "owner": "nvim-telescope", + "repo": "telescope-project.nvim", + "type": "github" + } + }, + "toggleterm-nvim-src": { + "flake": false, + "locked": { + "lastModified": 1667475764, + "narHash": "sha256-gazqaTsK5hAFqk6OONqTsR/zmjN3P8fPKsYufBhkeRA=", + "owner": "akinsho", + "repo": "toggleterm.nvim", + "rev": "3ba683827c623affb4d9aa518e97b34db2623093", + "type": "github" + }, + "original": { + "owner": "akinsho", + "repo": "toggleterm.nvim", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1659877975, @@ -217,6 +606,54 @@ "type": "github" } }, + "vim-bbye-src": { + "flake": false, + "locked": { + "lastModified": 1520078493, + "narHash": "sha256-xJMZQ/27TgwAnvPVH1fjF6SLOA9jvXmbfcwV0NZ1kTY=", + "owner": "moll", + "repo": "vim-bbye", + "rev": "25ef93ac5a87526111f43e5110675032dbcacf56", + "type": "github" + }, + "original": { + "owner": "moll", + "repo": "vim-bbye", + "type": "github" + } + }, + "vim-repeat-src": { + "flake": false, + "locked": { + "lastModified": 1611544268, + "narHash": "sha256-8rfZa3uKXB3TRCqaDHZ6DfzNbm7WaYnLvmTNzYtnKHg=", + "owner": "tpope", + "repo": "vim-repeat", + "rev": "24afe922e6a05891756ecf331f39a1f6743d3d5a", + "type": "github" + }, + "original": { + "owner": "tpope", + "repo": "vim-repeat", + "type": "github" + } + }, + "vim-surround-src": { + "flake": false, + "locked": { + "lastModified": 1666730476, + "narHash": "sha256-DZE5tkmnT+lAvx/RQHaDEgEJXRKsy56KJY919xiH1lE=", + "owner": "tpope", + "repo": "vim-surround", + "rev": "3d188ed2113431cf8dac77be61b842acb64433d9", + "type": "github" + }, + "original": { + "owner": "tpope", + "repo": "vim-surround", + "type": "github" + } + }, "wallpapers": { "flake": false, "locked": { @@ -236,8 +673,8 @@ "wsl": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_3" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1666720338, diff --git a/flake.nix b/flake.nix index f8aa770..6cc5f03 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,93 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + # Convert Nix to Neovim config + nix2vim = { + url = "github:gytis-ivaskevicius/nix2vim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Nix language server + nil.url = "github:oxalica/nil"; + + # Neovim plugins + nvim-lspconfig-src = { + url = "github:neovim/nvim-lspconfig"; + flake = false; + }; + cmp-nvim-lsp-src = { + url = "github:hrsh7th/cmp-nvim-lsp"; + flake = false; + }; + cmp-buffer-src = { + url = "github:hrsh7th/cmp-buffer"; + flake = false; + }; + plenary-nvim-src = { + url = "github:nvim-lua/plenary.nvim"; + flake = false; + }; + null-ls-nvim-src = { + url = "github:jose-elias-alvarez/null-ls.nvim"; + flake = false; + }; + vim-surround-src = { + url = "github:tpope/vim-surround"; + flake = false; + }; + vim-repeat-src = { + url = "github:tpope/vim-repeat"; + flake = false; + }; + Comment-nvim-src = { + url = "github:numToStr/Comment.nvim"; + flake = false; + }; + impatient-nvim-src = { + url = "github:lewis6991/impatient.nvim"; + flake = false; + }; + nvim-treesitter-src = { + url = "github:nvim-treesitter/nvim-treesitter"; + flake = false; + }; + telescope-nvim-src = { + url = "github:nvim-telescope/telescope.nvim"; + flake = false; + }; + telescope-project-nvim-src = { + url = "github:nvim-telescope/telescope-project.nvim"; + flake = false; + }; + toggleterm-nvim-src = { + url = "github:akinsho/toggleterm.nvim"; + flake = false; + }; + gitsigns-nvim-src = { + url = "github:lewis6991/gitsigns.nvim"; + flake = false; + }; + lualine-nvim-src = { + url = "github:hoob3rt/lualine.nvim"; + flake = false; + }; + nvim-web-devicons-src = { + url = "github:kyazdani42/nvim-web-devicons"; + flake = false; + }; + bufferline-nvim-src = { + url = "github:akinsho/bufferline.nvim"; + flake = false; + }; + vim-bbye-src = { + url = "github:moll/vim-bbye"; + flake = false; + }; + nvim-tree-lua-src = { + url = "github:kyazdani42/nvim-tree.lua"; + flake = false; + }; + }; outputs = { self, nixpkgs, ... }@inputs: @@ -86,10 +173,23 @@ }; # Package servers into images with a generator - packages.aws = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] - (system: { + packages = forAllSystems (system: { + + aws = { "${system}" = import ./hosts/aws { inherit inputs globals system; }; - }); + }; + + neovim = let + pkgs = import nixpkgs { + inherit system; + overlays = [ + (import ./modules/neovim/plugins-overlay.nix inputs) + inputs.nix2vim.overlay + ]; + }; + in pkgs.neovimBuilder { package = pkgs.neovim-unwrapped; }; + + }); apps = forAllSystems (system: let pkgs = import nixpkgs { inherit system; }; diff --git a/modules/neovim/plugins-overlay.nix b/modules/neovim/plugins-overlay.nix new file mode 100644 index 0000000..5296426 --- /dev/null +++ b/modules/neovim/plugins-overlay.nix @@ -0,0 +1,53 @@ +# Adopted from here: https://github.com/DieracDelta/vimconfig/blob/801b62dd56cfee59574639904a6c95b525725f66/plugins.nix + +inputs: final: prev: + +let + + # Use nixpkgs vimPlugin but with source directly from plugin author + withSrc = pkg: src: pkg.overrideAttrs (_: { inherit src; }); + + # Package plugin + plugin = pname: src: + prev.vimUtils.buildVimPluginFrom2Nix { + inherit pname src; + version = "master"; + }; + +in { + + nil = inputs.nil.packages.${prev.system}.nil; + + nvim-lspconfig = + (withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig); + cmp-nvim-lsp = (withSrc prev.vimPlugins.cmp-nvim-lsp inputs.cmp-nvim-lsp); + cmp-buffer = (withSrc prev.vimPlugins.cmp-buffer inputs.cmp-buffer); + plenary-nvim = (withSrc prev.vimPlugins.plenary-nvim inputs.plenary-nvim); + null-ls-nvim = (withSrc prev.vimPlugins.null-ls-nvim inputs.null-ls-nvim); + vim-surround = (withSrc prev.vimPlugins.vim-surround inputs.vim-surround); + vim-repeat = (withSrc prev.vimPlugins.vim-repeat inputs.vim-repeat); + comment-nvim = (withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim); + impatient-nvim = + (withSrc prev.vimPlugins.impatient-nvim inputs.impatient-nvim); + nvim-treesitter = + (withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter); + telescope-nvim = + (withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim); + telescope-project-nvim = (withSrc prev.vimPlugins.telescope-project-nvim + inputs.telescope-project-nvim); + toggleterm-nvim = + (withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim); + gitsigns-nvim = (withSrc prev.vimPlugins.gitsigns-nvim inputs.gitsigns-nvim); + lualine-nvim = (withSrc prev.vimPlugins.lualine-nvim inputs.lualine-nvim); + nvim-web-devicons = + (withSrc prev.vimPlugins.nvim-web-devicons inputs.nvim-web-devicons); + bufferline-nvim = + (withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim); + vim-bbye = (withSrc prev.vimPlugins.vim-bbye inputs.vim-bbye); + nvim-tree-lua = (withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua); + + # Packaging plugins with Nix + # comment-nvim = plugin "comment-nvim" comment-nvim-src; + # plenary-nvim = plugin "plenary-nvim" plenary-nvim-src; + +} From dc00ef26b51dec80a7482134b268f34226216824 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:08:33 -0700 Subject: [PATCH 128/391] some working stuff --- flake.nix | 50 ++++++++++++++++++++++++++++- modules/neovim/plugins/gitsigns.lua | 35 ++++++++++++++++++++ modules/neovim/plugins/gitsigns.nix | 7 ++++ modules/neovim/plugins/misc.nix | 17 ++++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 modules/neovim/plugins/gitsigns.lua create mode 100644 modules/neovim/plugins/gitsigns.nix create mode 100644 modules/neovim/plugins/misc.nix diff --git a/flake.nix b/flake.nix index 6cc5f03..99db524 100644 --- a/flake.nix +++ b/flake.nix @@ -187,7 +187,55 @@ inputs.nix2vim.overlay ]; }; - in pkgs.neovimBuilder { package = pkgs.neovim-unwrapped; }; + in pkgs.neovimBuilder { + package = pkgs.neovim-unwrapped; + imports = [ + ./modules/neovim/plugins/gitsigns.nix + ./modules/neovim/plugins/misc.nix + # ({ pkgs, dsl, ... }: + # # with dsl; + # { + # plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; + # setup.gitsigns = { }; + # lua = '' + # vim.keymap.set("", "", "", { silent = true }) + # vim.g.mapleader = " " + # vim.g.maplocalleader = " " + # local gitsigns = require("gitsigns") + # vim.keymap.set("n", "gB", gitsigns.blame_line) + # vim.keymap.set("n", "gp", gitsigns.preview_hunk) + # vim.keymap.set("v", "gp", gitsigns.preview_hunk) + # vim.keymap.set("n", "gd", gitsigns.diffthis) + # vim.keymap.set("v", "gd", gitsigns.diffthis) + # vim.keymap.set("n", "rgf", gitsigns.reset_buffer) + # vim.keymap.set("v", "hs", gitsigns.stage_hunk) + # vim.keymap.set("v", "hr", gitsigns.reset_hunk) + # vim.keymap.set("v", "hr", gitsigns.reset_hunk) + # + # -- Navigation + # vim.keymap.set("n", "]g", function() + # if vim.wo.diff then + # return "]g" + # end + # vim.schedule(function() + # gitsigns.next_hunk() + # end) + # return "" + # end, { expr = true }) + # + # vim.keymap.set("n", "[g", function() + # if vim.wo.diff then + # return "[g" + # end + # vim.schedule(function() + # gitsigns.prev_hunk() + # end) + # return "" + # end, { expr = true }) + # ''; + # }) + ]; + }; }); diff --git a/modules/neovim/plugins/gitsigns.lua b/modules/neovim/plugins/gitsigns.lua new file mode 100644 index 0000000..d38efe9 --- /dev/null +++ b/modules/neovim/plugins/gitsigns.lua @@ -0,0 +1,35 @@ +vim.keymap.set("", "", "", { silent = true }) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local gitsigns = require("gitsigns") +vim.keymap.set("n", "gB", gitsigns.blame_line) +vim.keymap.set("n", "gp", gitsigns.preview_hunk) +vim.keymap.set("v", "gp", gitsigns.preview_hunk) +vim.keymap.set("n", "gd", gitsigns.diffthis) +vim.keymap.set("v", "gd", gitsigns.diffthis) +vim.keymap.set("n", "rgf", gitsigns.reset_buffer) +vim.keymap.set("v", "hs", gitsigns.stage_hunk) +vim.keymap.set("v", "hr", gitsigns.reset_hunk) +vim.keymap.set("v", "hr", gitsigns.reset_hunk) + +-- Navigation +vim.keymap.set("n", "]g", function() + if vim.wo.diff then + return "]g" + end + vim.schedule(function() + gitsigns.next_hunk() + end) + return "" +end, { expr = true }) + +vim.keymap.set("n", "[g", function() + if vim.wo.diff then + return "[g" + end + vim.schedule(function() + gitsigns.prev_hunk() + end) + return "" +end, { expr = true }) diff --git a/modules/neovim/plugins/gitsigns.nix b/modules/neovim/plugins/gitsigns.nix new file mode 100644 index 0000000..3e64083 --- /dev/null +++ b/modules/neovim/plugins/gitsigns.nix @@ -0,0 +1,7 @@ +{ pkgs, dsl, ... }: +# with dsl; +{ + plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; + setup.gitsigns = { }; + lua = builtins.readFile ./gitsigns.lua; +} diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/plugins/misc.nix new file mode 100644 index 0000000..154d179 --- /dev/null +++ b/modules/neovim/plugins/misc.nix @@ -0,0 +1,17 @@ +{ pkgs, dsl, ... }: +# with dsl; +{ + plugins = [ + pkgs.vimPlugins.vim-surround + pkgs.vimPlugins.vim-eunuch + pkgs.vimPlugins.vim-vinegar + pkgs.vimPlugins.vim-fugitive + pkgs.vimPlugins.vim-repeat + pkgs.vimPlugins.comment-nvim + ]; + setup.Comment = { }; + lua = '' + ${builtins.readFile ../lua/keybinds.lua}; + ${builtins.readFile ../lua/settings.lua}; + ''; +} From bb200016cbc900362ec31f64d30a27fc21a4dc59 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:09:34 -0700 Subject: [PATCH 129/391] note about necessary plugins --- neovim-plugins.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 neovim-plugins.md diff --git a/neovim-plugins.md b/neovim-plugins.md new file mode 100644 index 0000000..c35f1a9 --- /dev/null +++ b/neovim-plugins.md @@ -0,0 +1,64 @@ +# Neovim Plugins + +## Must-haves + +- neovim/nvim-lspconfig: enable LSP +- hrsh7th/cmp-nvim-lsp: connect LSP to nvim-cmp +- hrsh7th/cmp-buffer: completion from current buffer +- nvim-lua/plenary.nvim: utility functions for other plugins +- jose-elias-alvarez/null-ls.nvim: auto-trigger linting, formatting +- tpope/vim-surround: surround shortcuts +- tpope/vim-repeat: better repeat with . +- numToStr/Comment.nvim: smart comment shortcut +- lewis6991/impatient.nvim: faster start time +- nvim-treesitter/nvim-treesitter: language parsers +- nvim-telescope/telescope.nvim: fuzzy finder +- nvim-telescope/telescope-project.nvim: jump projects +- akinsho/toggleterm.nvim: embedded floating terminal +- lewis6991/gitsigns.nvim: git in sidebar +- hoob3rt/lualine.nvim: status bar +- kyazdani42/nvim-web-devicons: icons in status bar +- akinsho/bufferline.nvim: tab view for buffers +- moll/vim-bbye: fixes for buffer closing +- kyazdani42/nvim-tree.lua: better sidebar explorer + +## Optional + +- hrsh7th/cmp-path: completion of file path +- hrsh7th/cmp-cmdline: completion of shell commands +- hrsh7th/cmp-nvim-lua: completion of neovim commands +- L3MON4D3/LuaSnip: snippet engine +- saadparwaiz1/cmp_luasnip: completion of luasnip snippets +- lukas-reineke/cmp-rg: completion of ripgrep search +- rafamadriz/friendly-snippets: pre-generated snippets +- folke/lsp-colors.nvim: LSP error highlights +- tpope/vim-eunuch: file manipulation +- tpope/vim-vinegar: better netrw file explorer +- tpope/vim-fugitive: git commands +- godlygeek/tabular: alignment commands +- jakewvincent/mkdnflow.nvim: markdown notes +- nvim-treesitter/nvim-treesitter-textobjects: syntax-aware textobjects +- chr4/nginx.vim: nginx syntax +- towolf/vim-helm: helm syntax +- rodjek/vim-puppet: puppet syntax +- nvim-telescope/telescope-fzy-native.nvim: faster sorting +- jvgrootveld/telescope-zoxide: jump directories +- nvim-telescope/telescope-file-browser.nvim: view files +- ellisonleao/glow.nvim: view markdown with glow +- norcalli/nvim-colorizer.lua: preview hex colors + +# Other Tools + +- git +- stylua +- black +- flake8 +- fish_indent +- nixfmt +- rustfmt +- shellcheck +- shfmt +- terraform +- luacheck +- markdownlint +- pylint From 13e5b9ddc5e83b35242aa25451be652913ca303b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:10:01 -0700 Subject: [PATCH 130/391] brewfile syntax no longer needed --- modules/neovim/lua/packer/syntax.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/neovim/lua/packer/syntax.lua b/modules/neovim/lua/packer/syntax.lua index 434c137..1a28bc7 100644 --- a/modules/neovim/lua/packer/syntax.lua +++ b/modules/neovim/lua/packer/syntax.lua @@ -64,7 +64,6 @@ M.packer = function(use) }) -- Additional syntax sources - use("bfontaine/Brewfile.vim") --- Brewfile syntax use("chr4/nginx.vim") --- Nginx syntax use("towolf/vim-helm") --- Helm syntax use("rodjek/vim-puppet") --- Puppet syntax From d86534727e17cd0def712ffb02d8c24db926f391 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:10:22 -0700 Subject: [PATCH 131/391] start of a WIP rebuild app --- apps/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/default.nix b/apps/default.nix index f0076ff..f390eee 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -8,6 +8,15 @@ # Display the readme for this repository readme = import ./readme.nix { inherit pkgs; }; + # Rebuild + rebuild = { + type = "app"; + program = builtins.toString (pkgs.writeShellScript "rebuild" '' + echo ${pkgs.system} + echo ${if pkgs.stdenv.isDarwin then "darwin" else "linux"} + ''); + }; + # Load the SSH key for this machine loadkey = import ./loadkey.nix { inherit pkgs; }; From 47a1823af4f9a1545fd80495c31dd305f81345f1 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 17:21:18 -0700 Subject: [PATCH 132/391] more working plugins --- flake.lock | 103 +++--------------------- flake.nix | 74 ++---------------- modules/neovim/lua/settings.lua | 39 +--------- modules/neovim/plugins-overlay.nix | 8 +- modules/neovim/plugins/bufferline.nix | 22 ++++++ modules/neovim/plugins/misc.nix | 35 ++++++++- modules/neovim/plugins/statusline.nix | 9 +++ modules/neovim/plugins/syntax.nix | 52 +++++++++++++ modules/neovim/plugins/telescope.nix | 108 ++++++++++++++++++++++++++ 9 files changed, 244 insertions(+), 206 deletions(-) create mode 100644 modules/neovim/plugins/bufferline.nix create mode 100644 modules/neovim/plugins/statusline.nix create mode 100644 modules/neovim/plugins/syntax.nix create mode 100644 modules/neovim/plugins/telescope.nix diff --git a/flake.lock b/flake.lock index d671881..2116ff4 100644 --- a/flake.lock +++ b/flake.lock @@ -202,22 +202,6 @@ "type": "github" } }, - "impatient-nvim-src": { - "flake": false, - "locked": { - "lastModified": 1668271823, - "narHash": "sha256-tsdTHbUC0kYOGonJ1TLIsHnv/RgWGTqHKY3xVj80mxM=", - "owner": "lewis6991", - "repo": "impatient.nvim", - "rev": "d3dd30ff0b811756e735eb9020609fa315bfbbcc", - "type": "github" - }, - "original": { - "owner": "lewis6991", - "repo": "impatient.nvim", - "type": "github" - } - }, "lualine-nvim-src": { "flake": false, "locked": { @@ -453,38 +437,6 @@ "type": "github" } }, - "nvim-web-devicons-src": { - "flake": false, - "locked": { - "lastModified": 1669423115, - "narHash": "sha256-Wyd4HnV+aQrh4Z2KdwCdi84glzIbQt8/y7NRGf67hcw=", - "owner": "kyazdani42", - "repo": "nvim-web-devicons", - "rev": "189ad3790d57c548896a78522fd8b0d0fc11be31", - "type": "github" - }, - "original": { - "owner": "kyazdani42", - "repo": "nvim-web-devicons", - "type": "github" - } - }, - "plenary-nvim-src": { - "flake": false, - "locked": { - "lastModified": 1664607953, - "narHash": "sha256-lIdBrVpi+vUudeotjFAuw4C0VT8TPoFE9cVVAQEsAYU=", - "owner": "nvim-lua", - "repo": "plenary.nvim", - "rev": "4b7e52044bbb84242158d977a50c4cbcd85070c7", - "type": "github" - }, - "original": { - "owner": "nvim-lua", - "repo": "plenary.nvim", - "type": "github" - } - }, "root": { "inputs": { "Comment-nvim-src": "Comment-nvim-src", @@ -495,7 +447,6 @@ "firefox-darwin": "firefox-darwin", "gitsigns-nvim-src": "gitsigns-nvim-src", "home-manager": "home-manager", - "impatient-nvim-src": "impatient-nvim-src", "lualine-nvim-src": "lualine-nvim-src", "nil": "nil", "nix2vim": "nix2vim", @@ -506,14 +457,10 @@ "nvim-lspconfig-src": "nvim-lspconfig-src", "nvim-tree-lua-src": "nvim-tree-lua-src", "nvim-treesitter-src": "nvim-treesitter-src", - "nvim-web-devicons-src": "nvim-web-devicons-src", - "plenary-nvim-src": "plenary-nvim-src", "telescope-nvim-src": "telescope-nvim-src", "telescope-project-nvim-src": "telescope-project-nvim-src", "toggleterm-nvim-src": "toggleterm-nvim-src", - "vim-bbye-src": "vim-bbye-src", - "vim-repeat-src": "vim-repeat-src", - "vim-surround-src": "vim-surround-src", + "vim-matchup-src": "vim-matchup-src", "wallpapers": "wallpapers", "wsl": "wsl" } @@ -606,51 +553,19 @@ "type": "github" } }, - "vim-bbye-src": { + "vim-matchup-src": { "flake": false, "locked": { - "lastModified": 1520078493, - "narHash": "sha256-xJMZQ/27TgwAnvPVH1fjF6SLOA9jvXmbfcwV0NZ1kTY=", - "owner": "moll", - "repo": "vim-bbye", - "rev": "25ef93ac5a87526111f43e5110675032dbcacf56", + "lastModified": 1668349349, + "narHash": "sha256-Btpninxq1B7/iIsn106hvPx1v5BPyLwADd2YcmliEZw=", + "owner": "andymass", + "repo": "vim-matchup", + "rev": "55e3330436784fb8ccc35a5cfeb13e48bab9dcd2", "type": "github" }, "original": { - "owner": "moll", - "repo": "vim-bbye", - "type": "github" - } - }, - "vim-repeat-src": { - "flake": false, - "locked": { - "lastModified": 1611544268, - "narHash": "sha256-8rfZa3uKXB3TRCqaDHZ6DfzNbm7WaYnLvmTNzYtnKHg=", - "owner": "tpope", - "repo": "vim-repeat", - "rev": "24afe922e6a05891756ecf331f39a1f6743d3d5a", - "type": "github" - }, - "original": { - "owner": "tpope", - "repo": "vim-repeat", - "type": "github" - } - }, - "vim-surround-src": { - "flake": false, - "locked": { - "lastModified": 1666730476, - "narHash": "sha256-DZE5tkmnT+lAvx/RQHaDEgEJXRKsy56KJY919xiH1lE=", - "owner": "tpope", - "repo": "vim-surround", - "rev": "3d188ed2113431cf8dac77be61b842acb64433d9", - "type": "github" - }, - "original": { - "owner": "tpope", - "repo": "vim-surround", + "owner": "andymass", + "repo": "vim-matchup", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 99db524..93cd82f 100644 --- a/flake.nix +++ b/flake.nix @@ -63,34 +63,22 @@ url = "github:hrsh7th/cmp-buffer"; flake = false; }; - plenary-nvim-src = { - url = "github:nvim-lua/plenary.nvim"; - flake = false; - }; null-ls-nvim-src = { url = "github:jose-elias-alvarez/null-ls.nvim"; flake = false; }; - vim-surround-src = { - url = "github:tpope/vim-surround"; - flake = false; - }; - vim-repeat-src = { - url = "github:tpope/vim-repeat"; - flake = false; - }; Comment-nvim-src = { url = "github:numToStr/Comment.nvim"; flake = false; }; - impatient-nvim-src = { - url = "github:lewis6991/impatient.nvim"; - flake = false; - }; nvim-treesitter-src = { url = "github:nvim-treesitter/nvim-treesitter"; flake = false; }; + vim-matchup-src = { + url = "github:andymass/vim-matchup"; + flake = false; + }; telescope-nvim-src = { url = "github:nvim-telescope/telescope.nvim"; flake = false; @@ -111,18 +99,10 @@ url = "github:hoob3rt/lualine.nvim"; flake = false; }; - nvim-web-devicons-src = { - url = "github:kyazdani42/nvim-web-devicons"; - flake = false; - }; bufferline-nvim-src = { url = "github:akinsho/bufferline.nvim"; flake = false; }; - vim-bbye-src = { - url = "github:moll/vim-bbye"; - flake = false; - }; nvim-tree-lua-src = { url = "github:kyazdani42/nvim-tree.lua"; flake = false; @@ -192,48 +172,10 @@ imports = [ ./modules/neovim/plugins/gitsigns.nix ./modules/neovim/plugins/misc.nix - # ({ pkgs, dsl, ... }: - # # with dsl; - # { - # plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; - # setup.gitsigns = { }; - # lua = '' - # vim.keymap.set("", "", "", { silent = true }) - # vim.g.mapleader = " " - # vim.g.maplocalleader = " " - # local gitsigns = require("gitsigns") - # vim.keymap.set("n", "gB", gitsigns.blame_line) - # vim.keymap.set("n", "gp", gitsigns.preview_hunk) - # vim.keymap.set("v", "gp", gitsigns.preview_hunk) - # vim.keymap.set("n", "gd", gitsigns.diffthis) - # vim.keymap.set("v", "gd", gitsigns.diffthis) - # vim.keymap.set("n", "rgf", gitsigns.reset_buffer) - # vim.keymap.set("v", "hs", gitsigns.stage_hunk) - # vim.keymap.set("v", "hr", gitsigns.reset_hunk) - # vim.keymap.set("v", "hr", gitsigns.reset_hunk) - # - # -- Navigation - # vim.keymap.set("n", "]g", function() - # if vim.wo.diff then - # return "]g" - # end - # vim.schedule(function() - # gitsigns.next_hunk() - # end) - # return "" - # end, { expr = true }) - # - # vim.keymap.set("n", "[g", function() - # if vim.wo.diff then - # return "[g" - # end - # vim.schedule(function() - # gitsigns.prev_hunk() - # end) - # return "" - # end, { expr = true }) - # ''; - # }) + ./modules/neovim/plugins/syntax.nix + ./modules/neovim/plugins/statusline.nix + ./modules/neovim/plugins/bufferline.nix + ./modules/neovim/plugins/telescope.nix ]; }; diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index b54e05a..ef447f7 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -2,42 +2,11 @@ -- Settings -- =========================================================================== -vim.o.termguicolors = true --- Set to truecolor -vim.o.hidden = true --- Don't unload buffers when leaving them -vim.wo.number = true --- Show line numbers -vim.wo.relativenumber = true --- Relative numbers instead of absolute -vim.o.list = true --- Reveal whitespace with dashes -vim.o.expandtab = true --- Tabs into spaces -vim.o.shiftwidth = 4 --- Amount to shift with > key -vim.o.softtabstop = 4 --- Amount to shift with key -vim.o.ignorecase = true --- Ignore case when searching -vim.o.smartcase = true --- Check case when using capitals in search -vim.o.infercase = true --- Don't match cases when completing suggestions -vim.o.incsearch = true --- Search while typing -vim.o.visualbell = true --- No sounds -vim.o.scrolljump = 1 --- Number of lines to scroll -vim.o.scrolloff = 3 --- Margin of lines to see while scrolling -vim.o.splitright = true --- Vertical splits on the right side -vim.o.splitbelow = true --- Horizontal splits on the bottom side -vim.o.pastetoggle = "" --- Use F3 to enter raw paste mode -vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking -vim.o.updatetime = 300 --- Faster diagnostics -vim.o.mouse = "nv" --- Mouse interaction / scrolling - --- Neovim features -vim.o.inccommand = "split" --- Live preview search and replace ---- Required for nvim-cmp completion -vim.opt.completeopt = { - "menu", - "menuone", - "noselect", -} - -- Remember last position when reopening file vim.api.nvim_exec( [[ au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif -]], +]] , false ) @@ -54,7 +23,7 @@ vim.api.nvim_exec( if !isdirectory(&backupdir) call mkdir(&backupdir, "p") endif -]], +]] , false ) @@ -63,7 +32,7 @@ vim.api.nvim_exec( [[ au FileType tex inoremap ;bf \textbf{}i au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! -]], +]] , false ) @@ -71,7 +40,7 @@ vim.api.nvim_exec( vim.api.nvim_exec( [[ au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } -]], +]] , false ) diff --git a/modules/neovim/plugins-overlay.nix b/modules/neovim/plugins-overlay.nix index 5296426..274ad5b 100644 --- a/modules/neovim/plugins-overlay.nix +++ b/modules/neovim/plugins-overlay.nix @@ -24,13 +24,10 @@ in { cmp-buffer = (withSrc prev.vimPlugins.cmp-buffer inputs.cmp-buffer); plenary-nvim = (withSrc prev.vimPlugins.plenary-nvim inputs.plenary-nvim); null-ls-nvim = (withSrc prev.vimPlugins.null-ls-nvim inputs.null-ls-nvim); - vim-surround = (withSrc prev.vimPlugins.vim-surround inputs.vim-surround); - vim-repeat = (withSrc prev.vimPlugins.vim-repeat inputs.vim-repeat); comment-nvim = (withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim); - impatient-nvim = - (withSrc prev.vimPlugins.impatient-nvim inputs.impatient-nvim); nvim-treesitter = (withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter); + vim-matchup = (withSrc prev.vimPlugins.vim-matchup inputs.vim-matchup); telescope-nvim = (withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim); telescope-project-nvim = (withSrc prev.vimPlugins.telescope-project-nvim @@ -39,11 +36,8 @@ in { (withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim); gitsigns-nvim = (withSrc prev.vimPlugins.gitsigns-nvim inputs.gitsigns-nvim); lualine-nvim = (withSrc prev.vimPlugins.lualine-nvim inputs.lualine-nvim); - nvim-web-devicons = - (withSrc prev.vimPlugins.nvim-web-devicons inputs.nvim-web-devicons); bufferline-nvim = (withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim); - vim-bbye = (withSrc prev.vimPlugins.vim-bbye inputs.vim-bbye); nvim-tree-lua = (withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua); # Packaging plugins with Nix diff --git a/modules/neovim/plugins/bufferline.nix b/modules/neovim/plugins/bufferline.nix new file mode 100644 index 0000000..73a6514 --- /dev/null +++ b/modules/neovim/plugins/bufferline.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: { + plugins = [ + pkgs.vimPlugins.bufferline-nvim + pkgs.vimPlugins.vim-bbye # Better closing of buffers + ]; + setup.bufferline = { + options = { + diagnostics = "nvim_lsp"; + always_show_bufferline = false; + separator_style = "slant"; + offsets = [{ filetype = "NvimTree"; }]; + }; + }; + lua = '' + -- Move buffers + vim.keymap.set("n", "L", ":BufferLineCycleNext", { silent = true }) + vim.keymap.set("n", "H", ":BufferLineCyclePrev", { silent = true }) + + -- Kill buffer + vim.keymap.set("n", "x", " :Bdelete", { silent = true }) + ''; +} diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/plugins/misc.nix index 154d179..3223e7e 100644 --- a/modules/neovim/plugins/misc.nix +++ b/modules/neovim/plugins/misc.nix @@ -1,6 +1,4 @@ -{ pkgs, dsl, ... }: -# with dsl; -{ +{ pkgs, lib, ... }: { plugins = [ pkgs.vimPlugins.vim-surround pkgs.vimPlugins.vim-eunuch @@ -8,9 +6,38 @@ pkgs.vimPlugins.vim-fugitive pkgs.vimPlugins.vim-repeat pkgs.vimPlugins.comment-nvim + pkgs.vimPlugins.impatient-nvim ]; setup.Comment = { }; - lua = '' + + vim.o.termguicolors = true; # Set to truecolor + vim.o.hidden = true; # Don't unload buffers when leaving them + vim.wo.number = true; # Show line numbers + vim.wo.relativenumber = true; # Relative numbers instead of absolute + vim.o.list = true; # Reveal whitespace with dashes + vim.o.expandtab = true; # Tabs into spaces + vim.o.shiftwidth = 4; # Amount to shift with > key + vim.o.softtabstop = 4; # Amount to shift with key + vim.o.ignorecase = true; # Ignore case when searching + vim.o.smartcase = true; # Check case when using capitals in search + vim.o.infercase = true; # Don't match cases when completing suggestions + vim.o.incsearch = true; # Search while typing + vim.o.visualbell = true; # No sounds + vim.o.scrolljump = 1; # Number of lines to scroll + vim.o.scrolloff = 3; # Margin of lines to see while scrolling + vim.o.splitright = true; # Vertical splits on the right side + vim.o.splitbelow = true; # Horizontal splits on the bottom side + vim.o.pastetoggle = ""; # Use F3 to enter raw paste mode + vim.o.clipboard = "unnamedplus"; # Uses system clipboard for yanking + vim.o.updatetime = 300; # Faster diagnostics + vim.o.mouse = "nv"; # Mouse interaction / scrolling + vim.o.inccommand = "split"; # Live preview search and replace + + # Required for nvim-cmp completion + vim.opt.completeopt = [ "menu" "menuone" "noselect" ]; + + lua = lib.mkBefore '' + require("impatient") ${builtins.readFile ../lua/keybinds.lua}; ${builtins.readFile ../lua/settings.lua}; ''; diff --git a/modules/neovim/plugins/statusline.nix b/modules/neovim/plugins/statusline.nix new file mode 100644 index 0000000..96c8bf7 --- /dev/null +++ b/modules/neovim/plugins/statusline.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + plugins = [ pkgs.vimPlugins.lualine-nvim ]; + setup.lualine = { + options = { + theme = "gruvbox"; + icons_enabled = true; + }; + }; +} diff --git a/modules/neovim/plugins/syntax.nix b/modules/neovim/plugins/syntax.nix new file mode 100644 index 0000000..0f223e5 --- /dev/null +++ b/modules/neovim/plugins/syntax.nix @@ -0,0 +1,52 @@ +{ pkgs, ... }: { + + plugins = [ + (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: + with pkgs.tree-sitter-grammars; [ + tree-sitter-hcl + tree-sitter-python + tree-sitter-lua + tree-sitter-nix + tree-sitter-fish + tree-sitter-toml + tree-sitter-yaml + tree-sitter-json + ])) + pkgs.vimPlugins.vim-matchup # Better % jumping in languages + pkgs.vimPlugins.nginx-vim + pkgs.vimPlugins.vim-helm + pkgs.vimPlugins.vim-puppet + ]; + + setup."nvim-treesitter.configs" = { + highlight = { enable = true; }; + indent = { enable = true; }; + + textobjects = { + select = { + enable = true; + lookahead = true; # Jump forward automatically + + keymaps = { + "['af']" = "@function.outer"; + "['if']" = "@function.inner"; + "['ac']" = "@class.outer"; + "['ic']" = "@class.inner"; + "['al']" = "@loop.outer"; + "['il']" = "@loop.inner"; + "['aa']" = "@call.outer"; + "['ia']" = "@call.inner"; + "['ar']" = "@parameter.outer"; + "['ir']" = "@parameter.inner"; + "['aC']" = "@comment.outer"; + "['iC']" = "@comment.outer"; + "['a/']" = "@comment.outer"; + "['i/']" = "@comment.outer"; + "['a;']" = "@statement.outer"; + "['i;']" = "@statement.outer"; + }; + }; + }; + }; + +} diff --git a/modules/neovim/plugins/telescope.nix b/modules/neovim/plugins/telescope.nix new file mode 100644 index 0000000..7fad646 --- /dev/null +++ b/modules/neovim/plugins/telescope.nix @@ -0,0 +1,108 @@ +{ pkgs, dsl, ... }: + +with dsl; + +{ + + plugins = [ + pkgs.vimPlugins.telescope-nvim + pkgs.vimPlugins.telescope-project-nvim + pkgs.vimPlugins.telescope-fzy-native-nvim + pkgs.vimPlugins.telescope-file-browser-nvim + pkgs.vimPlugins.telescope-zoxide + ]; + + setup.telescope = { + defaults = { + mappings = { + i = { + "['']" = rawLua "require('telescope.actions').close"; + "['']" = "which_key"; + }; + }; + }; + pickers = { + find_files = { theme = "ivy"; }; + oldfiles = { theme = "ivy"; }; + buffers = { theme = "dropdown"; }; + }; + extensions = { + fzy_native = { }; + zoxide = { }; + project = { base_dirs = [ "~/dev" ]; }; + }; + }; + + lua = '' + local telescope = require("telescope.builtin") + vim.keymap.set("n", "k", telescope.keymaps) + vim.keymap.set("n", "/", telescope.live_grep) + vim.keymap.set("n", "ff", telescope.find_files) + vim.keymap.set("n", "fp", telescope.git_files) + vim.keymap.set("n", "fw", telescope.grep_string) + vim.keymap.set("n", "b", telescope.buffers) + vim.keymap.set("n", "hh", telescope.help_tags) + vim.keymap.set("n", "fr", telescope.oldfiles) + vim.keymap.set("n", "cc", telescope.commands) + vim.keymap.set("n", "gc", telescope.git_commits) + vim.keymap.set("n", "gf", telescope.git_bcommits) + vim.keymap.set("n", "gb", telescope.git_branches) + vim.keymap.set("n", "gs", telescope.git_status) + vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) + + vim.keymap.set("n", "N", function() + local opts = { + prompt_title = "Search Notes", + cwd = "$NOTES_PATH", + } + telescope.live_grep(opts) + end) + + vim.keymap.set("n", "fN", function() + local opts = { + prompt_title = "Find Notes", + cwd = "$NOTES_PATH", + } + telescope.find_files(opts) + end) + + vim.keymap.set("n", "cr", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 15, + }, + }, + }) + telescope.command_history(opts) + end) + + -- zoxide + vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) + + -- project + require("telescope").load_extension("project") + vim.keymap.set("n", "", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 10, + }, + }, + }) + require("telescope").extensions.project.project(opts) + end) + + -- file browser + require("telescope").load_extension("file_browser") + vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) + vim.keymap.set("n", "fD", function() + local opts = { + prompt_title = "Find Downloads", + cwd = "~/downloads", + } + require("telescope").extensions.file_browser.file_browser(opts) + end) + ''; + +} From 96c64c4da11ee83bb9bce64a4706afe904530351 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 19:11:41 -0700 Subject: [PATCH 133/391] add lsp to neovim flake --- flake.nix | 1 + modules/neovim/lua/settings.lua | 50 +------------- modules/neovim/plugins/gitsigns.nix | 4 +- modules/neovim/plugins/lsp.nix | 97 ++++++++++++++++++++++++++++ modules/neovim/plugins/misc.nix | 34 +++++++--- modules/neovim/plugins/telescope.nix | 8 +-- 6 files changed, 128 insertions(+), 66 deletions(-) create mode 100644 modules/neovim/plugins/lsp.nix diff --git a/flake.nix b/flake.nix index 93cd82f..f4d25e8 100644 --- a/flake.nix +++ b/flake.nix @@ -176,6 +176,7 @@ ./modules/neovim/plugins/statusline.nix ./modules/neovim/plugins/bufferline.nix ./modules/neovim/plugins/telescope.nix + ./modules/neovim/plugins/lsp.nix ]; }; diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index ef447f7..a6896c9 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -2,63 +2,15 @@ -- Settings -- =========================================================================== --- Remember last position when reopening file -vim.api.nvim_exec( - [[ - au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif -]] , - false -) - --- Better backup, swap and undo storage -vim.o.backup = true --- Easier to recover and more secure -vim.bo.swapfile = false --- Instead of swaps, create backups -vim.bo.undofile = true --- Keeps undos after quit - --- Create backup directories if they don't exist --- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433 -vim.o.backupdir = vim.fn.stdpath("cache") .. "/backup" -vim.api.nvim_exec( - [[ - if !isdirectory(&backupdir) - call mkdir(&backupdir, "p") - endif -]] , - false -) - --- LaTeX options -vim.api.nvim_exec( - [[ - au FileType tex inoremap ;bf \textbf{}i - au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! -]] , - false -) - --- Highlight when yanking -vim.api.nvim_exec( - [[ - au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } -]] , - false -) - vim.filetype.add({ pattern = { [".*%.tfvars"] = "terraform", }, }) + vim.api.nvim_create_autocmd("FileType", { pattern = "*.eml", callback = function() vim.o.wrapmargin = 79 -- Wrap text automatically end, }) - --- Netrw -vim.g.netrw_liststyle = 3 -- Change style to 'tree' view -vim.g.netrw_banner = 0 -- Remove useless banner -vim.g.netrw_winsize = 15 -- Explore window takes % of page -vim.g.netrw_browse_split = 4 -- Open in previous window -vim.g.netrw_altv = 1 -- Always split left diff --git a/modules/neovim/plugins/gitsigns.nix b/modules/neovim/plugins/gitsigns.nix index 3e64083..06777cf 100644 --- a/modules/neovim/plugins/gitsigns.nix +++ b/modules/neovim/plugins/gitsigns.nix @@ -1,6 +1,4 @@ -{ pkgs, dsl, ... }: -# with dsl; -{ +{ pkgs, ... }: { plugins = [ pkgs.vimPlugins.gitsigns-nvim ]; setup.gitsigns = { }; lua = builtins.readFile ./gitsigns.lua; diff --git a/modules/neovim/plugins/lsp.nix b/modules/neovim/plugins/lsp.nix new file mode 100644 index 0000000..5f0e5e0 --- /dev/null +++ b/modules/neovim/plugins/lsp.nix @@ -0,0 +1,97 @@ +{ pkgs, dsl, ... }: { + + plugins = [ + pkgs.vimPlugins.nvim-lspconfig + pkgs.vimPlugins.lsp-colors-nvim + pkgs.vimPlugins.null-ls-nvim + ]; + + use.lspconfig.sumneko_lua.setup = dsl.callWith { + settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; }; + capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; + cmd = [ "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" ]; + }; + + use.lspconfig.nil_ls.setup = dsl.callWith { + cmd = [ "${pkgs.nil}/bin/nil" ]; + capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; + }; + + use.lspconfig.pyright.setup = dsl.callWith { + cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ]; + }; + + use.lspconfig.terraformls.setup = + dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-lsp" ]; }; + + vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; + + # setup."null-ls" = { + # sources = [ + # (dsl.rawLua + # "require('null-ls').builtins.formatting.black.with({ command = ${pkgs.black}/bin/black })") + # (dsl.rawLua + # "require('null-ls').builtins.formatting.flake8.with({ command = ${pkgs.python310Packages.flake8}/bin/flake8 })") + # (dsl.rawLua + # "require('null-ls').builtins.formatting.fish_indent.with({ command = ${pkgs.fish}/bin/fish_indent })") + # (dsl.rawLua + # "require('null-ls').builtins.formatting.nixfmt.with({ command = ${pkgs.nixfmt}/bin/nixfmt })") + # (dsl.rawLua + # "require('null-ls').builtins.formatting.rustfmt.with({ command = ${pkgs.rustfmt}/bin/rustfmt })") + # (dsl.rawLua + # "require('null-ls').builtins.diagnostics.shellcheck.with({ command = ${pkgs.shellcheck}/bin/shellcheck })") + # (dsl.rawLua '' + # require('null-ls').builtins.formatting.shfmt.with( + # command = {${pkgs.shfmt}/bin/shfmt }, + # extra_args = { '-i', '4', '-ci' }, + # )'') + # (dsl.rawLua + # "require('null-ls').builtins.formatting.terraform_fmt.with({ command = ${pkgs.terraform}/bin/terraform })") + # ]; + # }; + + lua = '' + vim.keymap.set("n", "gd", vim.lsp.buf.definition) + vim.keymap.set("n", "gT", vim.lsp.buf.type_definition) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation) + vim.keymap.set("n", "gh", vim.lsp.buf.hover) + -- vim.keymap.set("n", "gr", telescope.lsp_references) + vim.keymap.set("n", "R", vim.lsp.buf.rename) + vim.keymap.set("n", "]e", vim.diagnostic.goto_next) + vim.keymap.set("n", "[e", vim.diagnostic.goto_prev) + vim.keymap.set("n", "de", vim.diagnostic.open_float) + vim.keymap.set("n", "E", vim.lsp.buf.code_action) + + + require("null-ls").setup({ + sources = { + require('null-ls').builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }), + require('null-ls').builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }), + require('null-ls').builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }), + require('null-ls').builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }), + require('null-ls').builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }), + require('null-ls').builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }), + require('null-ls').builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }), + require('null-ls').builtins.formatting.shfmt.with({ + command = "${pkgs.shfmt}/bin/shfmt", + extra_args = { '-i', '4', '-ci' }, + }), + require('null-ls').builtins.formatting.terraform_fmt.with({ command = "${pkgs.terraform}/bin/terraform" }), + }, + + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end + }) + ''; + +} diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/plugins/misc.nix index 3223e7e..a8f632b 100644 --- a/modules/neovim/plugins/misc.nix +++ b/modules/neovim/plugins/misc.nix @@ -1,13 +1,13 @@ -{ pkgs, lib, ... }: { +{ pkgs, dsl, lib, ... }: { plugins = [ - pkgs.vimPlugins.vim-surround - pkgs.vimPlugins.vim-eunuch - pkgs.vimPlugins.vim-vinegar - pkgs.vimPlugins.vim-fugitive - pkgs.vimPlugins.vim-repeat - pkgs.vimPlugins.comment-nvim - pkgs.vimPlugins.impatient-nvim + pkgs.vimPlugins.vim-surround # Keybinds for surround characters + pkgs.vimPlugins.vim-eunuch # File manipulation commands + pkgs.vimPlugins.vim-fugitive # Git commands + pkgs.vimPlugins.vim-repeat # Better repeat using . + pkgs.vimPlugins.comment-nvim # Smart comment commands + pkgs.vimPlugins.impatient-nvim # Faster load times ]; + setup.Comment = { }; vim.o.termguicolors = true; # Set to truecolor @@ -33,6 +33,12 @@ vim.o.mouse = "nv"; # Mouse interaction / scrolling vim.o.inccommand = "split"; # Live preview search and replace + # Better backup, swap and undo storage + vim.o.backup = true; # Easier to recover and more secure + vim.bo.swapfile = false; # Instead of swaps, create backups + vim.bo.undofile = true; # Keeps undos after quit + vim.o.backupdir = dsl.rawLua ''vim.fn.stdpath("cache") .. "/backup"''; + # Required for nvim-cmp completion vim.opt.completeopt = [ "menu" "menuone" "noselect" ]; @@ -41,4 +47,16 @@ ${builtins.readFile ../lua/keybinds.lua}; ${builtins.readFile ../lua/settings.lua}; ''; + + vimscript = '' + " Remember last position when reopening file + au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + + " LaTeX options + au FileType tex inoremap ;bf \textbf{}i + au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! + + " Flash highlight when yanking + au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } + ''; } diff --git a/modules/neovim/plugins/telescope.nix b/modules/neovim/plugins/telescope.nix index 7fad646..efcfe72 100644 --- a/modules/neovim/plugins/telescope.nix +++ b/modules/neovim/plugins/telescope.nix @@ -1,8 +1,4 @@ -{ pkgs, dsl, ... }: - -with dsl; - -{ +{ pkgs, dsl, ... }: { plugins = [ pkgs.vimPlugins.telescope-nvim @@ -16,7 +12,7 @@ with dsl; defaults = { mappings = { i = { - "['']" = rawLua "require('telescope.actions').close"; + "['']" = dsl.rawLua "require('telescope.actions').close"; "['']" = "which_key"; }; }; From 8b98b8f29d3cf6772cc954a19c07e3b6ff83cc05 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 22:31:17 -0700 Subject: [PATCH 134/391] working completion --- flake.nix | 1 + modules/neovim/plugins/completion.nix | 155 ++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 modules/neovim/plugins/completion.nix diff --git a/flake.nix b/flake.nix index f4d25e8..e8f414f 100644 --- a/flake.nix +++ b/flake.nix @@ -177,6 +177,7 @@ ./modules/neovim/plugins/bufferline.nix ./modules/neovim/plugins/telescope.nix ./modules/neovim/plugins/lsp.nix + ./modules/neovim/plugins/completion.nix ]; }; diff --git a/modules/neovim/plugins/completion.nix b/modules/neovim/plugins/completion.nix new file mode 100644 index 0000000..d38aac5 --- /dev/null +++ b/modules/neovim/plugins/completion.nix @@ -0,0 +1,155 @@ +{ pkgs, dsl, ... }: { + + plugins = [ + pkgs.vimPlugins.cmp-nvim-lsp + pkgs.vimPlugins.cmp-buffer + pkgs.vimPlugins.cmp-path + pkgs.vimPlugins.cmp-cmdline + pkgs.vimPlugins.cmp-nvim-lua + pkgs.vimPlugins.luasnip + pkgs.vimPlugins.cmp_luasnip + pkgs.vimPlugins.cmp-rg + pkgs.vimPlugins.friendly-snippets + ]; + + use.cmp.setup = dsl.callWith { + + # Disable in telescope buffers + enabled = dsl.rawLua '' + function() + if vim.bo.buftype == "prompt" then + return false + end + return true + end + ''; + + snippet.expand = dsl.rawLua '' + function(args) + require("luasnip").lsp_expand(args.body) + end + ''; + + mapping = { + "['']" = dsl.rawLua + "require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })"; + "['']" = dsl.rawLua + "require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })"; + "['']" = dsl.rawLua + "require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })"; + "['']" = dsl.rawLua + "require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })"; + "['']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)"; + "['']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)"; + "['']" = dsl.rawLua "require('cmp').mapping.abort()"; + "['']" = dsl.rawLua + "require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })"; + "['']" = dsl.rawLua + "require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })"; + "['']" = dsl.rawLua '' + function(_) + cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }) + vim.cmd("stopinsert") --- Abort and leave insert mode + end + ''; + "['']" = dsl.rawLua '' + cmp.mapping(function(_) + if require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + end + end, { "i", "s" }) + ''; + }; + + sources = [ + { name = "nvim_lua"; } + { name = "nvim_lsp"; } + { name = "luasnip"; } + { name = "path"; } + { + name = "buffer"; + keyword_length = 3; + max_item_count = 10; + } + { + name = "rg"; + keyword_length = 6; + max_item_count = 10; + option = { additional_arguments = "--ignore-case"; }; + } + ]; + + formatting = { + fields = [ "kind" "abbr" "menu" ]; + format = dsl.rawLua '' + function(entry, vim_item) + local kind_icons = { + Text = "", + Method = "m", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + } + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + vim_item.menu = ({ + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + rg = "[Grep]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + })[entry.source.name] + return vim_item + end + ''; + }; + + experimental = { + native_menu = false; # Use cmp menu instead of Vim menu + ghost_text = true; # Show preview auto-completion + }; + + }; + + lua = '' + -- Use buffer source for `/` + require('cmp').setup.cmdline("/", { + sources = { + { name = "buffer", keyword_length = 5 }, + }, + }) + + -- Use cmdline & path source for ':' + require('cmp').setup.cmdline(":", { + sources = require('cmp').config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + ''; + +} From 0d052a64635b6be82cf6efbc7904f1c19b7a0e82 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 22:37:47 -0700 Subject: [PATCH 135/391] toggleterm for build --- flake.nix | 1 + modules/neovim/plugins/toggleterm.lua | 40 +++++++++++++++++++++++++++ modules/neovim/plugins/toggleterm.nix | 13 +++++++++ 3 files changed, 54 insertions(+) create mode 100644 modules/neovim/plugins/toggleterm.lua create mode 100644 modules/neovim/plugins/toggleterm.nix diff --git a/flake.nix b/flake.nix index e8f414f..87cd668 100644 --- a/flake.nix +++ b/flake.nix @@ -178,6 +178,7 @@ ./modules/neovim/plugins/telescope.nix ./modules/neovim/plugins/lsp.nix ./modules/neovim/plugins/completion.nix + ./modules/neovim/plugins/toggleterm.nix ]; }; diff --git a/modules/neovim/plugins/toggleterm.lua b/modules/neovim/plugins/toggleterm.lua new file mode 100644 index 0000000..7499132 --- /dev/null +++ b/modules/neovim/plugins/toggleterm.lua @@ -0,0 +1,40 @@ +vim.keymap.set("t", "", "") --- Exit terminal mode + +-- Only set these keymaps for toggleterm +vim.api.nvim_create_autocmd("TermOpen", { + pattern = "term://*toggleterm#*", + callback = function() + -- vim.keymap.set("t", "", "") --- Exit terminal mode + vim.keymap.set("t", "", "h") + vim.keymap.set("t", "", "j") + vim.keymap.set("t", "", "k") + vim.keymap.set("t", "", "l") + end, +}) + +local terminal = require("toggleterm.terminal").Terminal + +local basicterminal = terminal:new() +function TERM_TOGGLE() + basicterminal:toggle() +end + +local nixpkgs = terminal:new({ cmd = "nix repl ''" }) +function NIXPKGS_TOGGLE() + nixpkgs:toggle() +end + +local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" }) +function GITWATCH_TOGGLE() + gitwatch:toggle() +end + +local k9s = terminal:new({ cmd = "k9s" }) +function K9S_TOGGLE() + k9s:toggle() +end + +vim.keymap.set("n", "t", TERM_TOGGLE) +vim.keymap.set("n", "P", NIXPKGS_TOGGLE) +vim.keymap.set("n", "gw", GITWATCH_TOGGLE) +vim.keymap.set("n", "9", K9S_TOGGLE) diff --git a/modules/neovim/plugins/toggleterm.nix b/modules/neovim/plugins/toggleterm.nix new file mode 100644 index 0000000..ee67302 --- /dev/null +++ b/modules/neovim/plugins/toggleterm.nix @@ -0,0 +1,13 @@ +{ pkgs, dsl, ... }: { + + plugins = [ pkgs.vimPlugins.toggleterm-nvim ]; + + use.toggleterm.setup = dsl.callWith { + open_mapping = dsl.rawLua "[[]]"; + hide_numbers = true; + direction = "float"; + }; + + lua = builtins.readFile ./toggleterm.lua; + +} From dee7c7302ad72717309ec17fca78672595c21d8e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 27 Nov 2022 22:44:52 -0700 Subject: [PATCH 136/391] add gruvbox to neovim flake --- flake.nix | 1 + modules/colorscheme/gruvbox/neovim-gruvbox.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 modules/colorscheme/gruvbox/neovim-gruvbox.nix diff --git a/flake.nix b/flake.nix index 87cd668..ecb60a1 100644 --- a/flake.nix +++ b/flake.nix @@ -179,6 +179,7 @@ ./modules/neovim/plugins/lsp.nix ./modules/neovim/plugins/completion.nix ./modules/neovim/plugins/toggleterm.nix + ./modules/colorscheme/gruvbox/neovim-gruvbox.nix ]; }; diff --git a/modules/colorscheme/gruvbox/neovim-gruvbox.nix b/modules/colorscheme/gruvbox/neovim-gruvbox.nix new file mode 100644 index 0000000..9e46ff8 --- /dev/null +++ b/modules/colorscheme/gruvbox/neovim-gruvbox.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: { + + plugins = [ pkgs.vimPlugins.vim-gruvbox8 ]; + + vim.g.gruvbox_italicize_strings = 0; + vim.o.background = "dark"; + vimscript = '' + let g:gruvbox_italicize_strings = 0 + colorscheme gruvbox8 + ''; + +} From 34384463478574bfa2d5db036081b6bc5446c5af Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 28 Nov 2022 22:11:57 -0700 Subject: [PATCH 137/391] add nvim-tree to flake --- flake.nix | 1 + modules/neovim/plugins/misc.nix | 3 ++ modules/neovim/plugins/tree.nix | 75 +++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 modules/neovim/plugins/tree.nix diff --git a/flake.nix b/flake.nix index ecb60a1..5ab79a9 100644 --- a/flake.nix +++ b/flake.nix @@ -179,6 +179,7 @@ ./modules/neovim/plugins/lsp.nix ./modules/neovim/plugins/completion.nix ./modules/neovim/plugins/toggleterm.nix + ./modules/neovim/plugins/tree.nix ./modules/colorscheme/gruvbox/neovim-gruvbox.nix ]; }; diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/plugins/misc.nix index a8f632b..9ad3c89 100644 --- a/modules/neovim/plugins/misc.nix +++ b/modules/neovim/plugins/misc.nix @@ -6,9 +6,12 @@ pkgs.vimPlugins.vim-repeat # Better repeat using . pkgs.vimPlugins.comment-nvim # Smart comment commands pkgs.vimPlugins.impatient-nvim # Faster load times + pkgs.vimPlugins.glow-nvim # Markdown preview popup + pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews ]; setup.Comment = { }; + setup.colorizer = { }; vim.o.termguicolors = true; # Set to truecolor vim.o.hidden = true; # Don't unload buffers when leaving them diff --git a/modules/neovim/plugins/tree.nix b/modules/neovim/plugins/tree.nix new file mode 100644 index 0000000..0dc42ba --- /dev/null +++ b/modules/neovim/plugins/tree.nix @@ -0,0 +1,75 @@ +{ pkgs, dsl, ... }: { + + plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ]; + + # Disable netrw eagerly + # https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129 + vim.g.loaded = 1; + vim.g.loaded_netrwPlugin = 1; + + setup.nvim-tree = { + disable_netrw = true; + hijack_netrw = true; + update_focused_file = { + enable = true; + update_cwd = true; + ignore_list = { }; + }; + diagnostics = { + enable = true; + icons = { + hint = ""; + info = ""; + warning = ""; + error = ""; + }; + }; + renderer = { + icons = { + glyphs = { + git = { + unstaged = "~"; + staged = "+"; + unmerged = ""; + renamed = "➜"; + deleted = ""; + untracked = "?"; + ignored = "◌"; + }; + }; + }; + }; + view = { + width = 30; + hide_root_folder = false; + side = "left"; + mappings = { + custom_only = false; + list = [ + { + key = [ "l" "" "o" ]; + cb = dsl.rawLua + "require('nvim-tree.config').nvim_tree_callback('edit')"; + } + { + key = "h"; + cb = dsl.rawLua + "require('nvim-tree.config').nvim_tree_callback('close_node')"; + } + { + key = "v"; + cb = dsl.rawLua + "require('nvim-tree.config').nvim_tree_callback('vsplit')"; + } + ]; + }; + number = false; + relativenumber = false; + }; + }; + + lua = '' + vim.keymap.set("n", "e", ":NvimTreeFindFileToggle", { silent = true }) + ''; + +} From 7a39acef1a0b7367b0a518403987e661d46fcefc Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 28 Nov 2022 22:36:30 -0700 Subject: [PATCH 138/391] move some lua text to separate files --- modules/neovim/plugins/lsp.lua | 10 ++++ modules/neovim/plugins/lsp.nix | 54 +++++++++------------ modules/neovim/plugins/telescope.lua | 69 ++++++++++++++++++++++++++ modules/neovim/plugins/telescope.nix | 72 +--------------------------- 4 files changed, 102 insertions(+), 103 deletions(-) create mode 100644 modules/neovim/plugins/lsp.lua create mode 100644 modules/neovim/plugins/telescope.lua diff --git a/modules/neovim/plugins/lsp.lua b/modules/neovim/plugins/lsp.lua new file mode 100644 index 0000000..c32d416 --- /dev/null +++ b/modules/neovim/plugins/lsp.lua @@ -0,0 +1,10 @@ +vim.keymap.set("n", "gd", vim.lsp.buf.definition) +vim.keymap.set("n", "gT", vim.lsp.buf.type_definition) +vim.keymap.set("n", "gi", vim.lsp.buf.implementation) +vim.keymap.set("n", "gh", vim.lsp.buf.hover) +-- vim.keymap.set("n", "gr", telescope.lsp_references) +vim.keymap.set("n", "R", vim.lsp.buf.rename) +vim.keymap.set("n", "]e", vim.diagnostic.goto_next) +vim.keymap.set("n", "[e", vim.diagnostic.goto_prev) +vim.keymap.set("n", "de", vim.diagnostic.open_float) +vim.keymap.set("n", "E", vim.lsp.buf.code_action) diff --git a/modules/neovim/plugins/lsp.nix b/modules/neovim/plugins/lsp.nix index 5f0e5e0..c626515 100644 --- a/modules/neovim/plugins/lsp.nix +++ b/modules/neovim/plugins/lsp.nix @@ -51,46 +51,36 @@ # }; lua = '' - vim.keymap.set("n", "gd", vim.lsp.buf.definition) - vim.keymap.set("n", "gT", vim.lsp.buf.type_definition) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation) - vim.keymap.set("n", "gh", vim.lsp.buf.hover) - -- vim.keymap.set("n", "gr", telescope.lsp_references) - vim.keymap.set("n", "R", vim.lsp.buf.rename) - vim.keymap.set("n", "]e", vim.diagnostic.goto_next) - vim.keymap.set("n", "[e", vim.diagnostic.goto_prev) - vim.keymap.set("n", "de", vim.diagnostic.open_float) - vim.keymap.set("n", "E", vim.lsp.buf.code_action) - + ${builtins.readFile ./lsp.lua} require("null-ls").setup({ sources = { - require('null-ls').builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }), - require('null-ls').builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }), - require('null-ls').builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }), - require('null-ls').builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }), - require('null-ls').builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }), - require('null-ls').builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }), - require('null-ls').builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }), - require('null-ls').builtins.formatting.shfmt.with({ + require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }), + require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }), + require("null-ls").builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }), + require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }), + require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }), + require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }), + require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }), + require("null-ls").builtins.formatting.shfmt.with({ command = "${pkgs.shfmt}/bin/shfmt", - extra_args = { '-i', '4', '-ci' }, + extra_args = { "-i", "4", "-ci" }, }), - require('null-ls').builtins.formatting.terraform_fmt.with({ command = "${pkgs.terraform}/bin/terraform" }), + require("null-ls").builtins.formatting.terraform_fmt.with({ command = "${pkgs.terraform}/bin/terraform" }), }, on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ bufnr = bufnr }) - end, - }) - end - end + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end, }) ''; diff --git a/modules/neovim/plugins/telescope.lua b/modules/neovim/plugins/telescope.lua new file mode 100644 index 0000000..7cf47ef --- /dev/null +++ b/modules/neovim/plugins/telescope.lua @@ -0,0 +1,69 @@ +local telescope = require("telescope.builtin") +vim.keymap.set("n", "k", telescope.keymaps) +vim.keymap.set("n", "/", telescope.live_grep) +vim.keymap.set("n", "ff", telescope.find_files) +vim.keymap.set("n", "fp", telescope.git_files) +vim.keymap.set("n", "fw", telescope.grep_string) +vim.keymap.set("n", "b", telescope.buffers) +vim.keymap.set("n", "hh", telescope.help_tags) +vim.keymap.set("n", "fr", telescope.oldfiles) +vim.keymap.set("n", "cc", telescope.commands) +vim.keymap.set("n", "gc", telescope.git_commits) +vim.keymap.set("n", "gf", telescope.git_bcommits) +vim.keymap.set("n", "gb", telescope.git_branches) +vim.keymap.set("n", "gs", telescope.git_status) +vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) + +vim.keymap.set("n", "N", function() + local opts = { + prompt_title = "Search Notes", + cwd = "$NOTES_PATH", + } + telescope.live_grep(opts) +end) + +vim.keymap.set("n", "fN", function() + local opts = { + prompt_title = "Find Notes", + cwd = "$NOTES_PATH", + } + telescope.find_files(opts) +end) + +vim.keymap.set("n", "cr", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 15, + }, + }, + }) + telescope.command_history(opts) +end) + +-- Zoxide +vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) + +-- Project +require("telescope").load_extension("project") +vim.keymap.set("n", "", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 10, + }, + }, + }) + require("telescope").extensions.project.project(opts) +end) + +-- File browser +require("telescope").load_extension("file_browser") +vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) +vim.keymap.set("n", "fD", function() + local opts = { + prompt_title = "Find Downloads", + cwd = "~/downloads", + } + require("telescope").extensions.file_browser.file_browser(opts) +end) diff --git a/modules/neovim/plugins/telescope.nix b/modules/neovim/plugins/telescope.nix index efcfe72..e4ffacf 100644 --- a/modules/neovim/plugins/telescope.nix +++ b/modules/neovim/plugins/telescope.nix @@ -29,76 +29,6 @@ }; }; - lua = '' - local telescope = require("telescope.builtin") - vim.keymap.set("n", "k", telescope.keymaps) - vim.keymap.set("n", "/", telescope.live_grep) - vim.keymap.set("n", "ff", telescope.find_files) - vim.keymap.set("n", "fp", telescope.git_files) - vim.keymap.set("n", "fw", telescope.grep_string) - vim.keymap.set("n", "b", telescope.buffers) - vim.keymap.set("n", "hh", telescope.help_tags) - vim.keymap.set("n", "fr", telescope.oldfiles) - vim.keymap.set("n", "cc", telescope.commands) - vim.keymap.set("n", "gc", telescope.git_commits) - vim.keymap.set("n", "gf", telescope.git_bcommits) - vim.keymap.set("n", "gb", telescope.git_branches) - vim.keymap.set("n", "gs", telescope.git_status) - vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) - - vim.keymap.set("n", "N", function() - local opts = { - prompt_title = "Search Notes", - cwd = "$NOTES_PATH", - } - telescope.live_grep(opts) - end) - - vim.keymap.set("n", "fN", function() - local opts = { - prompt_title = "Find Notes", - cwd = "$NOTES_PATH", - } - telescope.find_files(opts) - end) - - vim.keymap.set("n", "cr", function() - local opts = require("telescope.themes").get_ivy({ - layout_config = { - bottom_pane = { - height = 15, - }, - }, - }) - telescope.command_history(opts) - end) - - -- zoxide - vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) - - -- project - require("telescope").load_extension("project") - vim.keymap.set("n", "", function() - local opts = require("telescope.themes").get_ivy({ - layout_config = { - bottom_pane = { - height = 10, - }, - }, - }) - require("telescope").extensions.project.project(opts) - end) - - -- file browser - require("telescope").load_extension("file_browser") - vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) - vim.keymap.set("n", "fD", function() - local opts = { - prompt_title = "Find Downloads", - cwd = "~/downloads", - } - require("telescope").extensions.file_browser.file_browser(opts) - end) - ''; + lua = builtins.readFile ./telescope.lua; } From 33e8a6bc9b5ac6d428d1181ddb997fe9ed329c4d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 09:35:39 -0700 Subject: [PATCH 139/391] refactor vim settings --- modules/neovim/plugins/lsp.nix | 24 ---------------- modules/neovim/plugins/misc.nix | 49 ++++++++++++++++++--------------- modules/neovim/plugins/tree.nix | 6 ++-- 3 files changed, 31 insertions(+), 48 deletions(-) diff --git a/modules/neovim/plugins/lsp.nix b/modules/neovim/plugins/lsp.nix index c626515..24d7808 100644 --- a/modules/neovim/plugins/lsp.nix +++ b/modules/neovim/plugins/lsp.nix @@ -26,30 +26,6 @@ vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; - # setup."null-ls" = { - # sources = [ - # (dsl.rawLua - # "require('null-ls').builtins.formatting.black.with({ command = ${pkgs.black}/bin/black })") - # (dsl.rawLua - # "require('null-ls').builtins.formatting.flake8.with({ command = ${pkgs.python310Packages.flake8}/bin/flake8 })") - # (dsl.rawLua - # "require('null-ls').builtins.formatting.fish_indent.with({ command = ${pkgs.fish}/bin/fish_indent })") - # (dsl.rawLua - # "require('null-ls').builtins.formatting.nixfmt.with({ command = ${pkgs.nixfmt}/bin/nixfmt })") - # (dsl.rawLua - # "require('null-ls').builtins.formatting.rustfmt.with({ command = ${pkgs.rustfmt}/bin/rustfmt })") - # (dsl.rawLua - # "require('null-ls').builtins.diagnostics.shellcheck.with({ command = ${pkgs.shellcheck}/bin/shellcheck })") - # (dsl.rawLua '' - # require('null-ls').builtins.formatting.shfmt.with( - # command = {${pkgs.shfmt}/bin/shfmt }, - # extra_args = { '-i', '4', '-ci' }, - # )'') - # (dsl.rawLua - # "require('null-ls').builtins.formatting.terraform_fmt.with({ command = ${pkgs.terraform}/bin/terraform })") - # ]; - # }; - lua = '' ${builtins.readFile ./lsp.lua} diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/plugins/misc.nix index 9ad3c89..7b56d1a 100644 --- a/modules/neovim/plugins/misc.nix +++ b/modules/neovim/plugins/misc.nix @@ -13,28 +13,33 @@ setup.Comment = { }; setup.colorizer = { }; - vim.o.termguicolors = true; # Set to truecolor - vim.o.hidden = true; # Don't unload buffers when leaving them - vim.wo.number = true; # Show line numbers - vim.wo.relativenumber = true; # Relative numbers instead of absolute - vim.o.list = true; # Reveal whitespace with dashes - vim.o.expandtab = true; # Tabs into spaces - vim.o.shiftwidth = 4; # Amount to shift with > key - vim.o.softtabstop = 4; # Amount to shift with key - vim.o.ignorecase = true; # Ignore case when searching - vim.o.smartcase = true; # Check case when using capitals in search - vim.o.infercase = true; # Don't match cases when completing suggestions - vim.o.incsearch = true; # Search while typing - vim.o.visualbell = true; # No sounds - vim.o.scrolljump = 1; # Number of lines to scroll - vim.o.scrolloff = 3; # Margin of lines to see while scrolling - vim.o.splitright = true; # Vertical splits on the right side - vim.o.splitbelow = true; # Horizontal splits on the bottom side - vim.o.pastetoggle = ""; # Use F3 to enter raw paste mode - vim.o.clipboard = "unnamedplus"; # Uses system clipboard for yanking - vim.o.updatetime = 300; # Faster diagnostics - vim.o.mouse = "nv"; # Mouse interaction / scrolling - vim.o.inccommand = "split"; # Live preview search and replace + vim.o = { + termguicolors = true; # Set to truecolor + hidden = true; # Don't unload buffers when leaving them + list = true; # Reveal whitespace with dashes + expandtab = true; # Tabs into spaces + shiftwidth = 4; # Amount to shift with > key + softtabstop = 4; # Amount to shift with key + ignorecase = true; # Ignore case when searching + smartcase = true; # Check case when using capitals in search + infercase = true; # Don't match cases when completing suggestions + incsearch = true; # Search while typing + visualbell = true; # No sounds + scrolljump = 1; # Number of lines to scroll + scrolloff = 3; # Margin of lines to see while scrolling + splitright = true; # Vertical splits on the right side + splitbelow = true; # Horizontal splits on the bottom side + pastetoggle = ""; # Use F3 to enter raw paste mode + clipboard = "unnamedplus"; # Uses system clipboard for yanking + updatetime = 300; # Faster diagnostics + mouse = "nv"; # Mouse interaction / scrolling + inccommand = "split"; # Live preview search and replace + }; + + vim.wo = { + number = true; # Show line numbers + relativenumber = true; # Relative numbers instead of absolute + }; # Better backup, swap and undo storage vim.o.backup = true; # Easier to recover and more secure diff --git a/modules/neovim/plugins/tree.nix b/modules/neovim/plugins/tree.nix index 0dc42ba..bffa3b4 100644 --- a/modules/neovim/plugins/tree.nix +++ b/modules/neovim/plugins/tree.nix @@ -4,8 +4,10 @@ # Disable netrw eagerly # https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129 - vim.g.loaded = 1; - vim.g.loaded_netrwPlugin = 1; + vim.g = { + loaded = 1; + loaded_netrwPlugin = 1; + }; setup.nvim-tree = { disable_netrw = true; From 397b08fab448c97199913a2d86f80e32b0308ac4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 09:44:10 -0700 Subject: [PATCH 140/391] remove more unnecessary plugin flake inputs --- flake.lock | 74 ++---------------------------- flake.nix | 16 ------- modules/neovim/plugins-overlay.nix | 5 -- 3 files changed, 3 insertions(+), 92 deletions(-) diff --git a/flake.lock b/flake.lock index 2116ff4..3bec7ed 100644 --- a/flake.lock +++ b/flake.lock @@ -32,22 +32,6 @@ "type": "github" } }, - "cmp-buffer-src": { - "flake": false, - "locked": { - "lastModified": 1660101488, - "narHash": "sha256-dG4U7MtnXThoa/PD+qFtCt76MQ14V1wX8GMYcvxEnbM=", - "owner": "hrsh7th", - "repo": "cmp-buffer", - "rev": "3022dbc9166796b644a841a02de8dd1cc1d311fa", - "type": "github" - }, - "original": { - "owner": "hrsh7th", - "repo": "cmp-buffer", - "type": "github" - } - }, "cmp-nvim-lsp-src": { "flake": false, "locked": { @@ -164,22 +148,6 @@ "type": "github" } }, - "gitsigns-nvim-src": { - "flake": false, - "locked": { - "lastModified": 1668016276, - "narHash": "sha256-u8nHB4QwP1hkfI64MGF5luTof88hTdpF5s1KBr3X2jE=", - "owner": "lewis6991", - "repo": "gitsigns.nvim", - "rev": "9ff7dfb051e5104088ff80556203634fc8f8546d", - "type": "github" - }, - "original": { - "owner": "lewis6991", - "repo": "gitsigns.nvim", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -202,22 +170,6 @@ "type": "github" } }, - "lualine-nvim-src": { - "flake": false, - "locked": { - "lastModified": 1669435324, - "narHash": "sha256-nbvFpC6/QEIwbnw1Zy4mEutpfI/lFKfPeTXUJmRIODc=", - "owner": "hoob3rt", - "repo": "lualine.nvim", - "rev": "b6314ac556098d7abea9bb8cf896d2e3500eca41", - "type": "github" - }, - "original": { - "owner": "hoob3rt", - "repo": "lualine.nvim", - "type": "github" - } - }, "nil": { "inputs": { "flake-utils": "flake-utils", @@ -313,11 +265,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1669165918, - "narHash": "sha256-hIVruk2+0wmw/Kfzy11rG3q7ev3VTi/IKVODeHcVjFo=", + "lastModified": 1669597967, + "narHash": "sha256-R+2NaDkXsYkOpFOhmVR8jBZ77Pq55Z6ilaqwFLLn000=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3b400a525d92e4085e46141ff48cbf89fd89739e", + "rev": "be9e3762e719211368d186f547f847737baad720", "type": "github" }, "original": { @@ -441,13 +393,10 @@ "inputs": { "Comment-nvim-src": "Comment-nvim-src", "bufferline-nvim-src": "bufferline-nvim-src", - "cmp-buffer-src": "cmp-buffer-src", "cmp-nvim-lsp-src": "cmp-nvim-lsp-src", "darwin": "darwin", "firefox-darwin": "firefox-darwin", - "gitsigns-nvim-src": "gitsigns-nvim-src", "home-manager": "home-manager", - "lualine-nvim-src": "lualine-nvim-src", "nil": "nil", "nix2vim": "nix2vim", "nixos-generators": "nixos-generators", @@ -460,7 +409,6 @@ "telescope-nvim-src": "telescope-nvim-src", "telescope-project-nvim-src": "telescope-project-nvim-src", "toggleterm-nvim-src": "toggleterm-nvim-src", - "vim-matchup-src": "vim-matchup-src", "wallpapers": "wallpapers", "wsl": "wsl" } @@ -553,22 +501,6 @@ "type": "github" } }, - "vim-matchup-src": { - "flake": false, - "locked": { - "lastModified": 1668349349, - "narHash": "sha256-Btpninxq1B7/iIsn106hvPx1v5BPyLwADd2YcmliEZw=", - "owner": "andymass", - "repo": "vim-matchup", - "rev": "55e3330436784fb8ccc35a5cfeb13e48bab9dcd2", - "type": "github" - }, - "original": { - "owner": "andymass", - "repo": "vim-matchup", - "type": "github" - } - }, "wallpapers": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 5ab79a9..a58f455 100644 --- a/flake.nix +++ b/flake.nix @@ -59,10 +59,6 @@ url = "github:hrsh7th/cmp-nvim-lsp"; flake = false; }; - cmp-buffer-src = { - url = "github:hrsh7th/cmp-buffer"; - flake = false; - }; null-ls-nvim-src = { url = "github:jose-elias-alvarez/null-ls.nvim"; flake = false; @@ -75,10 +71,6 @@ url = "github:nvim-treesitter/nvim-treesitter"; flake = false; }; - vim-matchup-src = { - url = "github:andymass/vim-matchup"; - flake = false; - }; telescope-nvim-src = { url = "github:nvim-telescope/telescope.nvim"; flake = false; @@ -91,14 +83,6 @@ url = "github:akinsho/toggleterm.nvim"; flake = false; }; - gitsigns-nvim-src = { - url = "github:lewis6991/gitsigns.nvim"; - flake = false; - }; - lualine-nvim-src = { - url = "github:hoob3rt/lualine.nvim"; - flake = false; - }; bufferline-nvim-src = { url = "github:akinsho/bufferline.nvim"; flake = false; diff --git a/modules/neovim/plugins-overlay.nix b/modules/neovim/plugins-overlay.nix index 274ad5b..a08dd2a 100644 --- a/modules/neovim/plugins-overlay.nix +++ b/modules/neovim/plugins-overlay.nix @@ -21,21 +21,16 @@ in { nvim-lspconfig = (withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig); cmp-nvim-lsp = (withSrc prev.vimPlugins.cmp-nvim-lsp inputs.cmp-nvim-lsp); - cmp-buffer = (withSrc prev.vimPlugins.cmp-buffer inputs.cmp-buffer); - plenary-nvim = (withSrc prev.vimPlugins.plenary-nvim inputs.plenary-nvim); null-ls-nvim = (withSrc prev.vimPlugins.null-ls-nvim inputs.null-ls-nvim); comment-nvim = (withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim); nvim-treesitter = (withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter); - vim-matchup = (withSrc prev.vimPlugins.vim-matchup inputs.vim-matchup); telescope-nvim = (withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim); telescope-project-nvim = (withSrc prev.vimPlugins.telescope-project-nvim inputs.telescope-project-nvim); toggleterm-nvim = (withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim); - gitsigns-nvim = (withSrc prev.vimPlugins.gitsigns-nvim inputs.gitsigns-nvim); - lualine-nvim = (withSrc prev.vimPlugins.lualine-nvim inputs.lualine-nvim); bufferline-nvim = (withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim); nvim-tree-lua = (withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua); From 650d1e91a2ad0bd01b06b99f82f89821a0e8e41f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 17:41:34 -0700 Subject: [PATCH 141/391] only remove firefox quit shortcut on linux --- modules/applications/firefox.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 3b1a246..ce817b3 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -34,7 +34,7 @@ settings = { "browser.aboutConfig.showWarning" = false; "browser.warnOnQuit" = false; - "browser.quitShortcut.disabled" = true; + "browser.quitShortcut.disabled" = lib.mkIf pkgs.stdenv.isLinux true; "browser.theme.dark-private-windows" = true; "browser.toolbars.bookmarks.visibility" = "newtab"; "browser.startup.page" = 3; # Restore previous session From dfacb580ae1ffe721051c549c86b006d497ef3ac Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 19:14:14 -0700 Subject: [PATCH 142/391] partial setup of neovim for home config --- flake.nix | 49 ++++++++----------- hosts/macbook/default.nix | 2 +- modules/colorscheme/gruvbox/default.nix | 4 +- .../neovim/{plugins => config}/bufferline.nix | 0 .../neovim/{plugins => config}/completion.nix | 0 .../neovim/{plugins => config}/gitsigns.lua | 0 .../neovim/{plugins => config}/gitsigns.nix | 0 modules/neovim/{plugins => config}/lsp.lua | 0 modules/neovim/{plugins => config}/lsp.nix | 0 modules/neovim/{plugins => config}/misc.nix | 0 .../neovim/{plugins => config}/statusline.nix | 0 modules/neovim/{plugins => config}/syntax.nix | 0 .../neovim/{plugins => config}/telescope.lua | 0 .../neovim/{plugins => config}/telescope.nix | 0 .../neovim/{plugins => config}/toggleterm.lua | 0 .../neovim/{plugins => config}/toggleterm.nix | 0 modules/neovim/{plugins => config}/tree.nix | 0 modules/neovim/default.nix | 37 +++----------- modules/neovim/package/default.nix | 46 +++++++++++++++++ 19 files changed, 76 insertions(+), 62 deletions(-) rename modules/neovim/{plugins => config}/bufferline.nix (100%) rename modules/neovim/{plugins => config}/completion.nix (100%) rename modules/neovim/{plugins => config}/gitsigns.lua (100%) rename modules/neovim/{plugins => config}/gitsigns.nix (100%) rename modules/neovim/{plugins => config}/lsp.lua (100%) rename modules/neovim/{plugins => config}/lsp.nix (100%) rename modules/neovim/{plugins => config}/misc.nix (100%) rename modules/neovim/{plugins => config}/statusline.nix (100%) rename modules/neovim/{plugins => config}/syntax.nix (100%) rename modules/neovim/{plugins => config}/telescope.lua (100%) rename modules/neovim/{plugins => config}/telescope.nix (100%) rename modules/neovim/{plugins => config}/toggleterm.lua (100%) rename modules/neovim/{plugins => config}/toggleterm.nix (100%) rename modules/neovim/{plugins => config}/tree.nix (100%) create mode 100644 modules/neovim/package/default.nix diff --git a/flake.nix b/flake.nix index a58f455..ef16b31 100644 --- a/flake.nix +++ b/flake.nix @@ -108,6 +108,13 @@ dotfilesRepo = "git@github.com:nmasur/dotfiles"; }; + # Common overlays to always use + overlays = [ + inputs.nur.overlay + inputs.nix2vim.overlay + (import ./modules/neovim/plugins-overlay.nix inputs) + ]; + # System types to support. supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; @@ -118,13 +125,13 @@ in rec { nixosConfigurations = { - desktop = import ./hosts/desktop { inherit inputs globals; }; - wsl = import ./hosts/wsl { inherit inputs globals; }; - oracle = import ./hosts/oracle { inherit inputs globals; }; + desktop = import ./hosts/desktop { inherit inputs globals overlays; }; + wsl = import ./hosts/wsl { inherit inputs globals overlays; }; + oracle = import ./hosts/oracle { inherit inputs globals overlays; }; }; darwinConfigurations = { - macbook = import ./hosts/macbook { inherit inputs globals; }; + macbook = import ./hosts/macbook { inherit inputs globals overlays; }; }; # For quickly applying local settings with: @@ -140,42 +147,26 @@ packages = forAllSystems (system: { aws = { - "${system}" = import ./hosts/aws { inherit inputs globals system; }; + "${system}" = + import ./hosts/aws { inherit inputs globals system overlays; }; }; - neovim = let - pkgs = import nixpkgs { - inherit system; - overlays = [ - (import ./modules/neovim/plugins-overlay.nix inputs) - inputs.nix2vim.overlay - ]; + neovim = let pkgs = import nixpkgs { inherit system overlays; }; + in import ./modules/neovim/package { + inherit pkgs; + colors = import ./modules/colorscheme/gruvbox/neovim-gruvbox.nix { + inherit pkgs; }; - in pkgs.neovimBuilder { - package = pkgs.neovim-unwrapped; - imports = [ - ./modules/neovim/plugins/gitsigns.nix - ./modules/neovim/plugins/misc.nix - ./modules/neovim/plugins/syntax.nix - ./modules/neovim/plugins/statusline.nix - ./modules/neovim/plugins/bufferline.nix - ./modules/neovim/plugins/telescope.nix - ./modules/neovim/plugins/lsp.nix - ./modules/neovim/plugins/completion.nix - ./modules/neovim/plugins/toggleterm.nix - ./modules/neovim/plugins/tree.nix - ./modules/colorscheme/gruvbox/neovim-gruvbox.nix - ]; }; }); apps = forAllSystems (system: - let pkgs = import nixpkgs { inherit system; }; + let pkgs = import nixpkgs { inherit system overlays; }; in import ./apps { inherit pkgs; }); devShells = forAllSystems (system: - let pkgs = import nixpkgs { inherit system; }; + let pkgs = import nixpkgs { inherit system overlays; }; in { # Used to run commands and edit files in this repo diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 74e2f90..d3101d9 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -22,7 +22,7 @@ darwin.lib.darwinSystem { }; mailUser = globals.user; networking.hostName = "noah-masur-mac"; - nixpkgs.overlays = [ nur.overlay firefox-darwin.overlay ]; + nixpkgs.overlays = [ firefox-darwin.overlay ]; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; } diff --git a/modules/colorscheme/gruvbox/default.nix b/modules/colorscheme/gruvbox/default.nix index 07441ed..43bec39 100644 --- a/modules/colorscheme/gruvbox/default.nix +++ b/modules/colorscheme/gruvbox/default.nix @@ -19,7 +19,7 @@ base0D = "#83a598"; # blue base0E = "#d3869b"; # purple base0F = "#d65d0e"; # brown - neovimConfig = ./neovim.lua; + neovimConfig = ./neovim-gruvbox.nix; batTheme = "gruvbox-dark"; }; light = { @@ -39,7 +39,7 @@ base0D = "#076678"; # blue base0E = "#8f3f71"; # purple base0F = "#d65d0e"; # brown - neovimConfig = ./neovim.lua; + neovimConfig = ./neovim-gruvbox.nix; batTheme = "gruvbox-light"; }; } diff --git a/modules/neovim/plugins/bufferline.nix b/modules/neovim/config/bufferline.nix similarity index 100% rename from modules/neovim/plugins/bufferline.nix rename to modules/neovim/config/bufferline.nix diff --git a/modules/neovim/plugins/completion.nix b/modules/neovim/config/completion.nix similarity index 100% rename from modules/neovim/plugins/completion.nix rename to modules/neovim/config/completion.nix diff --git a/modules/neovim/plugins/gitsigns.lua b/modules/neovim/config/gitsigns.lua similarity index 100% rename from modules/neovim/plugins/gitsigns.lua rename to modules/neovim/config/gitsigns.lua diff --git a/modules/neovim/plugins/gitsigns.nix b/modules/neovim/config/gitsigns.nix similarity index 100% rename from modules/neovim/plugins/gitsigns.nix rename to modules/neovim/config/gitsigns.nix diff --git a/modules/neovim/plugins/lsp.lua b/modules/neovim/config/lsp.lua similarity index 100% rename from modules/neovim/plugins/lsp.lua rename to modules/neovim/config/lsp.lua diff --git a/modules/neovim/plugins/lsp.nix b/modules/neovim/config/lsp.nix similarity index 100% rename from modules/neovim/plugins/lsp.nix rename to modules/neovim/config/lsp.nix diff --git a/modules/neovim/plugins/misc.nix b/modules/neovim/config/misc.nix similarity index 100% rename from modules/neovim/plugins/misc.nix rename to modules/neovim/config/misc.nix diff --git a/modules/neovim/plugins/statusline.nix b/modules/neovim/config/statusline.nix similarity index 100% rename from modules/neovim/plugins/statusline.nix rename to modules/neovim/config/statusline.nix diff --git a/modules/neovim/plugins/syntax.nix b/modules/neovim/config/syntax.nix similarity index 100% rename from modules/neovim/plugins/syntax.nix rename to modules/neovim/config/syntax.nix diff --git a/modules/neovim/plugins/telescope.lua b/modules/neovim/config/telescope.lua similarity index 100% rename from modules/neovim/plugins/telescope.lua rename to modules/neovim/config/telescope.lua diff --git a/modules/neovim/plugins/telescope.nix b/modules/neovim/config/telescope.nix similarity index 100% rename from modules/neovim/plugins/telescope.nix rename to modules/neovim/config/telescope.nix diff --git a/modules/neovim/plugins/toggleterm.lua b/modules/neovim/config/toggleterm.lua similarity index 100% rename from modules/neovim/plugins/toggleterm.lua rename to modules/neovim/config/toggleterm.lua diff --git a/modules/neovim/plugins/toggleterm.nix b/modules/neovim/config/toggleterm.nix similarity index 100% rename from modules/neovim/plugins/toggleterm.nix rename to modules/neovim/config/toggleterm.nix diff --git a/modules/neovim/plugins/tree.nix b/modules/neovim/config/tree.nix similarity index 100% rename from modules/neovim/plugins/tree.nix rename to modules/neovim/config/tree.nix diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index a52b63e..50dffdf 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -2,29 +2,13 @@ home-manager.users.${config.user} = { - home.packages = with pkgs; [ - neovim - gcc # for tree-sitter - tree-sitter # for tree-sitter-gitignore parser - nodejs # for tree-sitter-gitignore parser - shfmt # used everywhere - shellcheck # used everywhere + home.packages = [ + (import ./package { + inherit pkgs; + colors = import config.theme.colors.neovimConfig { inherit pkgs; }; + }) ]; - xdg.configFile = { - "nvim/init.lua".source = ./init.lua; - "nvim/lua" = { - source = ./lua; - recursive = true; # Allows adding more files - }; - "nvim/lua/packer/colors.lua".source = config.theme.colors.neovimConfig; - "nvim/lua/background.lua".text = '' - vim.o.background = "${ - if config.theme.dark == true then "dark" else "light" - }" - ''; - }; - programs.git.extraConfig.core.editor = "nvim"; home.sessionVariables = { EDITOR = "nvim"; @@ -39,16 +23,9 @@ }; }; - # Always run packer.nvim sync - home.activation.nvimPackerSync = - config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - $DRY_RUN_CMD ${pkgs.neovim}/bin/nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' - ''; - }; - # Used for icons in Vim - fonts.fonts = with pkgs; [ nerdfonts ]; + # # Used for icons in Vim + # fonts.fonts = with pkgs; [ nerdfonts ]; } diff --git a/modules/neovim/package/default.nix b/modules/neovim/package/default.nix new file mode 100644 index 0000000..1e70496 --- /dev/null +++ b/modules/neovim/package/default.nix @@ -0,0 +1,46 @@ +# { inputs, globals, extraConfig ? [ ], ... }: +# +# let +# +# pkgs = import inputs.nixpkgs { +# system = inputs.system; +# overlays = [ +# (import ./modules/neovim/plugins-overlay.nix inputs) +# inputs.nix2vim.overlay +# ]; +# }; +# +# in pkgs.neovimBuilder { +# package = pkgs.neovim-unwrapped; +# imports = [ +# ./modules/neovim/plugins/bufferline.nix +# ./modules/neovim/plugins/completion.nix +# ./modules/neovim/plugins/gitsigns.nix +# ./modules/neovim/plugins/lsp.nix +# ./modules/neovim/plugins/misc.nix +# ./modules/neovim/plugins/statusline.nix +# ./modules/neovim/plugins/syntax.nix +# ./modules/neovim/plugins/telescope.nix +# ./modules/neovim/plugins/toggleterm.nix +# ./modules/neovim/plugins/tree.nix +# ] ++ extraConfig; +# } + +{ pkgs, colors ? { }, ... }: + +pkgs.neovimBuilder { + package = pkgs.neovim-unwrapped; + imports = [ + ../config/bufferline.nix + ../config/completion.nix + ../config/gitsigns.nix + ../config/lsp.nix + ../config/misc.nix + ../config/statusline.nix + ../config/syntax.nix + ../config/telescope.nix + ../config/toggleterm.nix + ../config/tree.nix + colors + ]; +} From b258a40181cc5eaaa92098c02907e2903febe5c6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 20:40:15 -0700 Subject: [PATCH 143/391] working flake build of neovim --- hosts/macbook/default.nix | 4 +-- modules/neovim/default.nix | 54 ++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index d3101d9..d350cc6 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -1,4 +1,4 @@ -{ inputs, globals, ... }: +{ inputs, globals, overlays, ... }: with inputs; @@ -22,7 +22,7 @@ darwin.lib.darwinSystem { }; mailUser = globals.user; networking.hostName = "noah-masur-mac"; - nixpkgs.overlays = [ firefox-darwin.overlay ]; + nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; } diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index 50dffdf..c435342 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -1,30 +1,38 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, lib, ... }: - home-manager.users.${config.user} = { - - home.packages = [ - (import ./package { - inherit pkgs; - colors = import config.theme.colors.neovimConfig { inherit pkgs; }; - }) - ]; - - programs.git.extraConfig.core.editor = "nvim"; - home.sessionVariables = { - EDITOR = "nvim"; - MANPAGER = "nvim +Man!"; - }; - programs.fish = { - shellAliases = { vim = "nvim"; }; - shellAbbrs = { - v = lib.mkForce "nvim"; - vl = lib.mkForce "vim -c 'normal! `0' -c 'bdelete 1'"; - vll = "nvim -c 'Telescope oldfiles'"; - }; - }; +let + neovim = import ./package { + inherit pkgs; + colors = import config.theme.colors.neovimConfig { inherit pkgs; }; }; +in { + + home-manager.users.${config.user} = + + { + + home.packages = [ neovim ]; + + programs.git.extraConfig.core.editor = "nvim"; + home.sessionVariables = { + EDITOR = "nvim"; + MANPAGER = "nvim +Man!"; + }; + programs.fish = { + shellAliases = { vim = "nvim"; }; + shellAbbrs = { + v = lib.mkForce "nvim"; + vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'"; + vll = "nvim -c 'Telescope oldfiles'"; + }; + }; + programs.kitty.settings.scrollback_pager = lib.mkForce '' + ${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; + + }; + # # Used for icons in Vim # fonts.fonts = with pkgs; [ nerdfonts ]; From 54e89d3acd98805c128a64d0b63ffbcdf1e633cd Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 20:48:46 -0700 Subject: [PATCH 144/391] add neovim as nix app --- README.md | 20 +++++++++------ apps/default.nix | 15 +++++++++++ neovim-plugins.md | 64 ----------------------------------------------- 3 files changed, 28 insertions(+), 71 deletions(-) delete mode 100644 neovim-plugins.md diff --git a/README.md b/README.md index cc3c7a5..9cb99e9 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,24 @@ configuration may be difficult to translate to a non-Nix system. However, some of the configurations are easier to lift directly: -- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/neovim/lua) +- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/neovim/config) - [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/shell/fish/functions) - [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/fish/default.nix) - [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/git.nix) - [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon) +Try out my Neovim config: + +```bash +nix run github:nmasur/dotfiles#neovim +``` + +Or build it as a package: + +```bash +nix build github:nmasur/dotfiles#neovim +``` + --- # Installation @@ -87,12 +99,6 @@ openssl s_client -showcerts -verify 5 -connect cache.nixos.org:443 < /dev/null sudo nvim $NIX_SSL_CERT_FILE ``` -### Dealing with Neovim issues: - -Update Neovim Packer plugins: `:PackerSync` - -Update TreeSitter languages: `:TSUpdateSync` - --- # Flake Templates diff --git a/apps/default.nix b/apps/default.nix index f0076ff..a630d66 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -20,4 +20,19 @@ # Connect machine metrics to Netdata Cloud netdata = import ./netdata-cloud.nix { inherit pkgs; }; + # Run neovim as an app + neovim = { + type = "app"; + program = "${ + (import ../modules/neovim/package { + inherit pkgs; + colors = import ../modules/colorscheme/gruvbox/neovim-gruvbox.nix { + inherit pkgs; + }; + }) + }/bin/nvim"; + }; + + nvim = neovim; + } diff --git a/neovim-plugins.md b/neovim-plugins.md deleted file mode 100644 index c35f1a9..0000000 --- a/neovim-plugins.md +++ /dev/null @@ -1,64 +0,0 @@ -# Neovim Plugins - -## Must-haves - -- neovim/nvim-lspconfig: enable LSP -- hrsh7th/cmp-nvim-lsp: connect LSP to nvim-cmp -- hrsh7th/cmp-buffer: completion from current buffer -- nvim-lua/plenary.nvim: utility functions for other plugins -- jose-elias-alvarez/null-ls.nvim: auto-trigger linting, formatting -- tpope/vim-surround: surround shortcuts -- tpope/vim-repeat: better repeat with . -- numToStr/Comment.nvim: smart comment shortcut -- lewis6991/impatient.nvim: faster start time -- nvim-treesitter/nvim-treesitter: language parsers -- nvim-telescope/telescope.nvim: fuzzy finder -- nvim-telescope/telescope-project.nvim: jump projects -- akinsho/toggleterm.nvim: embedded floating terminal -- lewis6991/gitsigns.nvim: git in sidebar -- hoob3rt/lualine.nvim: status bar -- kyazdani42/nvim-web-devicons: icons in status bar -- akinsho/bufferline.nvim: tab view for buffers -- moll/vim-bbye: fixes for buffer closing -- kyazdani42/nvim-tree.lua: better sidebar explorer - -## Optional - -- hrsh7th/cmp-path: completion of file path -- hrsh7th/cmp-cmdline: completion of shell commands -- hrsh7th/cmp-nvim-lua: completion of neovim commands -- L3MON4D3/LuaSnip: snippet engine -- saadparwaiz1/cmp_luasnip: completion of luasnip snippets -- lukas-reineke/cmp-rg: completion of ripgrep search -- rafamadriz/friendly-snippets: pre-generated snippets -- folke/lsp-colors.nvim: LSP error highlights -- tpope/vim-eunuch: file manipulation -- tpope/vim-vinegar: better netrw file explorer -- tpope/vim-fugitive: git commands -- godlygeek/tabular: alignment commands -- jakewvincent/mkdnflow.nvim: markdown notes -- nvim-treesitter/nvim-treesitter-textobjects: syntax-aware textobjects -- chr4/nginx.vim: nginx syntax -- towolf/vim-helm: helm syntax -- rodjek/vim-puppet: puppet syntax -- nvim-telescope/telescope-fzy-native.nvim: faster sorting -- jvgrootveld/telescope-zoxide: jump directories -- nvim-telescope/telescope-file-browser.nvim: view files -- ellisonleao/glow.nvim: view markdown with glow -- norcalli/nvim-colorizer.lua: preview hex colors - -# Other Tools - -- git -- stylua -- black -- flake8 -- fish_indent -- nixfmt -- rustfmt -- shellcheck -- shfmt -- terraform -- luacheck -- markdownlint -- pylint From d127ccacb0066c0dbfad2874365a162ac40c5672 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 29 Nov 2022 23:07:45 -0700 Subject: [PATCH 145/391] add declarative k9s color --- modules/programming/kubernetes.nix | 118 ++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/modules/programming/kubernetes.nix b/modules/programming/kubernetes.nix index 8a11640..3f4a849 100644 --- a/modules/programming/kubernetes.nix +++ b/modules/programming/kubernetes.nix @@ -4,7 +4,6 @@ home.packages = with pkgs; [ kubectl # Basic Kubernetes queries - k9s # Terminal Kubernetes UI kubernetes-helm # Helm CLI fluxcd # Bootstrap clusters with Flux kustomize # Kustomize CLI (for Flux) @@ -19,6 +18,123 @@ ks = "k9s"; }; + # Terminal Kubernetes UI + programs.k9s = { + enable = true; + # settings = { k9s = { headless = true; }; }; + skin = { + k9s = { + body = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + logoColor = config.theme.colors.base02; # *blue ? + }; + # Search bar + prompt = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + suggestColor = config.theme.colors.base03; + }; + # Header left side + info = { + fgColor = config.theme.colors.base04; + sectionColor = config.theme.colors.base05; + }; + dialog = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + buttonFgColor = config.theme.colors.base06; + buttonBgColor = config.theme.colors.base0E; + buttonFocusFgColor = config.theme.colors.base07; + buttonFocusBgColor = config.theme.colors.base02; # *cyan + labelFgColor = config.theme.colors.base09; + fieldFgColor = config.theme.colors.base06; + }; + frame = { + border = { + fgColor = config.theme.colors.base01; + focusColor = config.theme.colors.base06; + }; + menu = { + fgColor = config.theme.colors.base06; + keyColor = config.theme.colors.base0E; # *magenta + numKeyColor = config.theme.colors.base0E; # *magenta + }; + crumbs = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base01; + activeColor = config.theme.colors.base03; + }; + status = { + newColor = config.theme.colors.base04; # *cyan + modifyColor = config.theme.colors.base0D; # *blue + addColor = config.theme.colors.base0B; # *green + errorColor = config.theme.colors.base08; # *red + highlightColor = config.theme.colors.base09; # *orange + killColor = config.theme.colors.base03; # *comment + completedColor = config.theme.colors.base03; # *comment + }; + title = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + highlightColor = config.theme.colors.base09; # *orange + counterColor = config.theme.colors.base0D; # *blue + filterColor = config.theme.colors.base0E; # *magenta + }; + }; + views = { + charts = { + bgColor = config.theme.colors.base00; + defaultDialColors = + [ config.theme.colors.base0D config.theme.colors.base08 ]; + # - *blue + # - *red + defaultChartColors = + [ config.theme.colors.base0D config.theme.colors.base08 ]; + # - *blue + # - *red + }; + table = { + # List of resources + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + + # Row selection + cursorFgColor = config.theme.colors.base07; + cursorBgColor = config.theme.colors.base01; + + # Header row + header = { + fgColor = config.theme.colors.base0D; + bgColor = config.theme.colors.base00; + sorterColor = config.theme.colors.base0A; # *selection + }; + }; + xray = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + cursorColor = config.theme.colors.base06; + graphicColor = config.theme.colors.base0D; + showIcons = false; + }; + yaml = { + keyColor = config.theme.colors.base0D; + colonColor = config.theme.colors.base04; + fgColor = config.theme.colors.base03; + }; + logs = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + indicator = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + }; + }; + }; + }; + }; + }; + }; } From 74e346fa636fe50a2b3142162980b743849d2a7d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 30 Nov 2022 10:56:30 -0700 Subject: [PATCH 146/391] fix: bad command for terraform-ls --- modules/neovim/config/lsp.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/neovim/config/lsp.nix b/modules/neovim/config/lsp.nix index 24d7808..5a00369 100644 --- a/modules/neovim/config/lsp.nix +++ b/modules/neovim/config/lsp.nix @@ -22,7 +22,7 @@ }; use.lspconfig.terraformls.setup = - dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-lsp" ]; }; + dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; }; vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; From 427bd1a421f4efff24938b8d5579cd6786c67923 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 6 Dec 2022 10:03:06 -0700 Subject: [PATCH 147/391] update sources for nixos 22.11 --- flake.lock | 102 ++++++++++++++--------------- modules/mail/himalaya.nix | 4 +- modules/neovim/config/gitsigns.lua | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/flake.lock b/flake.lock index 3bec7ed..5a7170e 100644 --- a/flake.lock +++ b/flake.lock @@ -55,11 +55,11 @@ ] }, "locked": { - "lastModified": 1666776005, - "narHash": "sha256-HwSMF19PpczfqNHKcFsA6cF4PVbG00uUSdbq6q3jB5o=", + "lastModified": 1668784520, + "narHash": "sha256-gGgVAMwYPPmrfnvnoRi6OkEB5KRsNTb9uYzEceLdO/g=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "f6648ca0698d1611d7eadfa72b122252b833f86c", + "rev": "6349b99bc2b96ded34d068a88c7c5ced406b7f7f", "type": "github" }, "original": { @@ -135,11 +135,11 @@ }, "flake-utils_3": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1666903647, - "narHash": "sha256-sFI1Gh9DTGzHnBINondupUGYbe+T0wZcpcZjkW0qffM=", + "lastModified": 1670280307, + "narHash": "sha256-3x+0whP1nCz5adQMIsBA3L9fI/ABOpRUJdbw0AmxBnU=", "owner": "nix-community", "repo": "home-manager", - "rev": "213a06295dff96668a1d673b9fd1c03ce1de6745", + "rev": "2af0d07678fc15612345e0dd55337550dcf6465f", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1669391194, - "narHash": "sha256-4oWcXqyBYPHF+Wt8AxRhWk70O1qVJPkyBw2IhxJtj6k=", + "lastModified": 1670273694, + "narHash": "sha256-Rb+AIMyncKNnP0EahDg5w37v6TXlGtd2SczugSQzMQU=", "owner": "oxalica", "repo": "nil", - "rev": "afec5fed829ee193de7e8c62e1fb4bd55140f4ac", + "rev": "101387fb2f54ebc67c894979d1ae0efac2b4ad5c", "type": "github" }, "original": { @@ -234,11 +234,11 @@ ] }, "locked": { - "lastModified": 1666812839, - "narHash": "sha256-0nBDgjPU+iDsvz89W+cDEyhnFGSwCJmwDl/gMGqYiU0=", + "lastModified": 1669065280, + "narHash": "sha256-3+pq1oJWjGDLfd8G/vR3IIFZ+EQ/aglukA0bTiMlf3o=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "41f3518bc194389df22a3d198215eae75e6b5ab9", + "rev": "50aeec40f2072d2ab267c8ec8a345573704ec110", "type": "github" }, "original": { @@ -265,11 +265,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1669597967, - "narHash": "sha256-R+2NaDkXsYkOpFOhmVR8jBZ77Pq55Z6ilaqwFLLn000=", + "lastModified": 1669809720, + "narHash": "sha256-RMT77f6CPOYtLLQ2esj+EJ1BPVWxf4RDidjrSvA5OhI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "be9e3762e719211368d186f547f847737baad720", + "rev": "227de2b3bbec142f912c09d5e8a1b4e778aa54fb", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1666959691, - "narHash": "sha256-TRpWA3t8ata79HOGtFd5dDCl1kJQmIE16PDF53/Hcxo=", + "lastModified": 1670152712, + "narHash": "sha256-LJttwIvJqsZIj8u1LxVRv82vwUtkzVqQVi7Wb8gxPS4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "448a599c49978c2794401bfc3a2e1fba1a8663be", + "rev": "14ddeaebcbe9a25748221d1d7ecdf98e20e2325e", "type": "github" }, "original": { @@ -297,11 +297,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1660318005, - "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=", + "lastModified": 1667653703, + "narHash": "sha256-Xow4vx52/g5zkhlgZnMEm/TEXsj+13jTPCc2jIhW1xU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5c211b47aeadcc178c5320afd4e74c7eed5c389f", + "rev": "f09ad462c5a121d0239fde645aacb2221553a217", "type": "github" }, "original": { @@ -313,11 +313,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1669235424, - "narHash": "sha256-po66LOeGuBHi3MZsn5+/gYdgU+oFTZUPfPWx2norc3I=", + "lastModified": 1670247790, + "narHash": "sha256-fAqhpPJV53XmFQaJ7xnTOd+DKFLxGyfDnvSYW6ZOMQc=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "c51978f546a86a653f4a492b86313f4616412cec", + "rev": "b3d2ebdb75cf1fa4290822b43dc31f61bd0023f8", "type": "github" }, "original": { @@ -328,11 +328,11 @@ }, "nur": { "locked": { - "lastModified": 1667025500, - "narHash": "sha256-88akaieCIrqta3Uyha7Zv3FJWzKJebb2BrOdZba1zdI=", + "lastModified": 1670315682, + "narHash": "sha256-/v0RgZZIjvsFuJbJLUlzRbzSlYFXq3olgJTuJBNtcoY=", "owner": "nix-community", "repo": "nur", - "rev": "21dd192519af12a01f1348bbfa86cde47f7aa392", + "rev": "af814db16c89385c65e758608296440555f61ccc", "type": "github" }, "original": { @@ -344,11 +344,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1669447443, - "narHash": "sha256-ikrkXhzkn4nYqJd9WaG61UGYWRdY2cbzKQIR+kDcYqE=", + "lastModified": 1670318621, + "narHash": "sha256-cySTYqdmOktCmwC0mh6gJoGYzyfrOVqNtUBOV5RBSCw=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "abe6c99c7489de2c317869cf5dea57a9595a0cca", + "rev": "8faa599646f482d3ed04e645eb04af94bcd12feb", "type": "github" }, "original": { @@ -360,11 +360,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1669432749, - "narHash": "sha256-YQix8eYrruuyH5pzjFvxb6hbMLhu1X/hnymO9dmbCqs=", + "lastModified": 1670039798, + "narHash": "sha256-mQfo9KlNHbZtDIO3U8BZ7PGVBP5EtLUDpETq+bfqpVU=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "b17358ff4d822deeb42b97919065800f8f91cb55", + "rev": "f8489c992998e1e1b45aec65bdb9615e5cd59a61", "type": "github" }, "original": { @@ -376,11 +376,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1669484329, - "narHash": "sha256-aAzVCRoqa2TDMsDKuxFRJHleR4ubA0bLaCVYk96/su8=", + "lastModified": 1670321697, + "narHash": "sha256-lL9cPP7t852Zst1n0nWDp1r31Sx17T+xAiJvIylh4vo=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "5aacb06135a952190933f9bfff923957db8965db", + "rev": "7eb553ce4dc9af6631a823b5e4b5aa33fdc45bfd", "type": "github" }, "original": { @@ -425,11 +425,11 @@ ] }, "locked": { - "lastModified": 1669170936, - "narHash": "sha256-TKPH4Pzkjw5gAPo9hejs3O4mWJW6V/RSiOj8UuSFRTs=", + "lastModified": 1669775522, + "narHash": "sha256-6xxGArBqssX38DdHpDoPcPvB/e79uXyQBwpBcaO/BwY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c90c223c4aef334356029b89c72bb65e26f7efe6", + "rev": "3158e47f6b85a288d12948aeb9a048e0ed4434d6", "type": "github" }, "original": { @@ -441,11 +441,11 @@ "telescope-nvim-src": { "flake": false, "locked": { - "lastModified": 1669224375, - "narHash": "sha256-NqMtFHgYO031WLDHb7AuVRUFMA72LHYVjbD0bt26O6I=", + "lastModified": 1669979094, + "narHash": "sha256-5UgCqnDs4iubnq7gER1wC8Mk9UZuo8cWqDB8ZbyGCRI=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "cea9c75c19d172d2c6f089f21656019734a615cf", + "rev": "cabf991b1d3996fa6f3232327fc649bbdf676496", "type": "github" }, "original": { @@ -488,11 +488,11 @@ }, "utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -524,11 +524,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1666720338, - "narHash": "sha256-7V91ZtTz7zDXb6hivktQ9RlBglP+WEkYFSciPJHwMJw=", + "lastModified": 1669863592, + "narHash": "sha256-g0YVtM5Hi8k27yIWvPR7ZRRE1JscL6XtC5dv9Li1tMM=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "7bfb8f5aa91fee30a189eae32cda8ddc465076df", + "rev": "522219248de4b5876f18e47f34d979dd9f4fcbdc", "type": "github" }, "original": { diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 12748d3..4363dd5 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -7,9 +7,9 @@ programs.himalaya = { enable = true; }; accounts.email.accounts.home.himalaya = { enable = true; + backend = "imap"; + sender = "smtp"; settings = { - backend = "imap"; - sender = "smtp"; downloads-dir = config.userDirs.download; smtp-insecure = true; }; diff --git a/modules/neovim/config/gitsigns.lua b/modules/neovim/config/gitsigns.lua index d38efe9..398c085 100644 --- a/modules/neovim/config/gitsigns.lua +++ b/modules/neovim/config/gitsigns.lua @@ -10,7 +10,7 @@ vim.keymap.set("n", "gd", gitsigns.diffthis) vim.keymap.set("v", "gd", gitsigns.diffthis) vim.keymap.set("n", "rgf", gitsigns.reset_buffer) vim.keymap.set("v", "hs", gitsigns.stage_hunk) -vim.keymap.set("v", "hr", gitsigns.reset_hunk) +vim.keymap.set("n", "hr", gitsigns.reset_hunk) vim.keymap.set("v", "hr", gitsigns.reset_hunk) -- Navigation From 9b12369e43da6d581637cf4af862584fef23a7f1 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 6 Dec 2022 17:56:29 +0000 Subject: [PATCH 148/391] fixes for oracle when updating to latest --- hosts/oracle/default.nix | 5 +++-- modules/nixos/user.nix | 1 + modules/services/nextcloud.nix | 2 +- modules/services/prometheus.nix | 4 ++++ modules/services/transmission.nix | 4 ++++ modules/services/vaultwarden.nix | 1 + patches/calibre-web-cloudflare.patch | 20 ++++++++++---------- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index c8a9163..8bdbd64 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -1,4 +1,4 @@ -{ inputs, globals, ... }: +{ inputs, globals, overlays, ... }: with inputs; @@ -15,7 +15,8 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager { gui.enable = false; - colorscheme = (import ../../modules/colorscheme/gruvbox); + theme = { colors = (import ../../modules/colorscheme/gruvbox).dark; }; + nixpkgs.overlays = overlays; # FQDNs for various services networking.hostName = "oracle"; diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix index 24d0ff8..54a17a8 100644 --- a/modules/nixos/user.nix +++ b/modules/nixos/user.nix @@ -5,6 +5,7 @@ passwordHash = lib.mkOption { type = lib.types.nullOr lib.types.str; description = "Password created with mkpasswd -m sha-512"; + default = null; # Test it by running: mkpasswd -m sha-512 --salt "PZYiMGmJIIHAepTM" }; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 55d18eb..5feb598 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -15,7 +15,7 @@ services.nextcloud = { enable = true; - package = pkgs.nextcloud24; # Required to specify + package = pkgs.nextcloud25; # Required to specify https = true; hostName = "localhost"; maxUploadSize = "50G"; diff --git a/modules/services/prometheus.nix b/modules/services/prometheus.nix index 543540a..15e91ee 100644 --- a/modules/services/prometheus.nix +++ b/modules/services/prometheus.nix @@ -8,6 +8,10 @@ config = { services.grafana.enable = true; + + # Required to fix error in latest nixpkgs + services.grafana.settings = { }; + services.prometheus = { enable = true; exporters.node.enable = true; diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 7fd56ad..8c7e667 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -50,6 +50,10 @@ }]; }]; + # Caddy and Transmission both try to set rmem_max for larger UDP packets. + # We will choose Transmission's recommendation (4 MB). + boot.kernel.sysctl."net.core.rmem_max" = 4194304; + # Allow inbound connections to reach namespace systemd.services.transmission-web-netns = { description = "Forward to transmission in wireguard namespace"; diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index c8da296..d9cf20f 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -52,6 +52,7 @@ in { handle = [{ handler = "reverse_proxy"; upstreams = [{ dial = "localhost:8222"; }]; + headers.request.add."X-Real-IP" = [ "{http.request.remote.host}" ]; }]; }]; diff --git a/patches/calibre-web-cloudflare.patch b/patches/calibre-web-cloudflare.patch index 1e1363d..3378dcd 100644 --- a/patches/calibre-web-cloudflare.patch +++ b/patches/calibre-web-cloudflare.patch @@ -1,20 +1,20 @@ diff --git a/cps/__init__.py b/cps/__init__.py -index 0b912d23..ad5d1fa9 100644 +index 1ba1f778..da0bc718 100644 --- a/cps/__init__.py +++ b/cps/__init__.py -@@ -83,7 +83,6 @@ app.config.update( - lm = MyLoginManager() - lm.login_view = 'web.login' - lm.anonymous_user = ub.Anonymous --lm.session_protection = 'strong' +@@ -100,7 +100,6 @@ updater_thread = Updater() + def create_app(): + lm.login_view = 'web.login' + lm.anonymous_user = ub.Anonymous +- lm.session_protection = 'strong' - if wtf_present: - csrf = CSRFProtect() + if csrf: + csrf.init_app(app) diff --git a/cps/admin.py b/cps/admin.py -index 1004ee78..e295066e 100644 +index 09a553b4..5c646e46 100644 --- a/cps/admin.py +++ b/cps/admin.py -@@ -98,8 +98,6 @@ def before_request(): +@@ -104,8 +104,6 @@ def before_request(): # make remember me function work if current_user.is_authenticated: confirm_login() From 7d53a80d49bb61fdcd9616994c8ed443b9746a49 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 6 Dec 2022 17:40:13 -0700 Subject: [PATCH 149/391] add gum formatting for default app --- README.md | 4 ++++ apps/default.nix | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cb99e9..244ed4d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ Or build it as a package: nix build github:nmasur/dotfiles#neovim ``` +If you already have a Neovim configuration, you may need to move it out of +`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise, both +configs might conflict with each other. + --- # Installation diff --git a/apps/default.nix b/apps/default.nix index e50046f..f172bfb 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -1,6 +1,25 @@ { pkgs, ... }: rec { - default = readme; + default = { + type = "app"; + program = builtins.toString (pkgs.writeShellScript "default" '' + ${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options" + ${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.' + echo "" + echo "" + ${pkgs.gum}/bin/gum format --type=template -- \ + ' • {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \ + ' • {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \ + ' • {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \ + ' • {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \ + ' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \ + ' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \ + ' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \ + ' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}' + echo "" + echo "" + ''); + }; # Format and install from nothing installer = import ./installer.nix { inherit pkgs; }; From 2620b4392581e471ab80475e0cf389fff89ed944 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 10 Dec 2022 15:47:39 -0700 Subject: [PATCH 150/391] fix firefox colors on macos --- flake.lock | 6 +++--- modules/applications/firefox.nix | 32 ++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 5a7170e..50e5f9a 100644 --- a/flake.lock +++ b/flake.lock @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1668992358, - "narHash": "sha256-24iH+wIbE1bKCFmqslwOpfrDypJ40mk1uGIqRUxDXxY=", + "lastModified": 1670028550, + "narHash": "sha256-jrCEzbRfcNBSy0YHYPLpMSeoluryej3EuqdMZsR1bhQ=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "066d4fd658acd075b45405eda9e3bca6a71a47b1", + "rev": "8f3697c4ea0b138255a30b65510a25d393c4ce4c", "type": "github" }, "original": { diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index ce817b3..389b3a1 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -7,9 +7,10 @@ home-manager.users.${config.user} = { - programs.firefox = { + programs.firefox = rec { enable = true; - package = lib.mkIf pkgs.stdenv.isDarwin pkgs.firefox-bin; + package = + if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ ublock-origin vimium @@ -20,26 +21,33 @@ okta-browser-plugin sponsorblock reddit-enhancement-suite + return-youtube-dislikes bypass-paywalls-clean markdownload darkreader snowflake don-t-fuck-with-paste i-dont-care-about-cookies + wappalyzer ]; - profiles.Profile0 = { + profiles.default = { id = 0; name = "default"; isDefault = true; settings = { + "app.update.auto" = false; "browser.aboutConfig.showWarning" = false; "browser.warnOnQuit" = false; - "browser.quitShortcut.disabled" = lib.mkIf pkgs.stdenv.isLinux true; + "browser.quitShortcut.disabled" = + if pkgs.stdenv.isLinux then true else false; "browser.theme.dark-private-windows" = true; "browser.toolbars.bookmarks.visibility" = "newtab"; "browser.startup.page" = 3; # Restore previous session "browser.newtabpage.enabled" = false; # Make new tabs blank "dom.forms.autocomplete.formautofill" = false; # Disable autofill + "extensions.formautofill.creditCards.enabled" = + false; # Disable credit cards + "dom.payments.defaults.saveAddress" = false; # Disable address save "general.autoScroll" = true; # Drag middle-mouse to scroll "services.sync.prefs.sync.general.autoScroll" = false; # Prevent disabling autoscroll @@ -60,6 +68,22 @@ .toolbar-items { background-color: ${config.theme.colors.base00} !important; } + /* Extra tab bar sides on macOS */ + .titlebar-spacer { + background-color: ${config.theme.colors.base00} !important; + } + .titlebar-buttonbox-container { + background-color: ${config.theme.colors.base00} !important; + } + #tabbrowser-tabs { + border-inline-start: 0 !important; + } + /* Private Browsing indicator on macOS */ + #private-browsing-indicator-with-label { + background-color: ${config.theme.colors.base00} !important; + margin-inline: 0 !important; + padding-inline: 7px; + } /* Tabs themselves */ .tabbrowser-tab .tab-stack { border-radius: 5px 5px 0 0; From 1d8638777c35579be776e19ee57333f694701831 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 10 Dec 2022 15:48:05 -0700 Subject: [PATCH 151/391] enable rebuild app command --- apps/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/default.nix b/apps/default.nix index f172bfb..6c977d0 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -32,7 +32,12 @@ type = "app"; program = builtins.toString (pkgs.writeShellScript "rebuild" '' echo ${pkgs.system} - echo ${if pkgs.stdenv.isDarwin then "darwin" else "linux"} + SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"} + if [ "$SYSTEM" == "darwin" ]; then + darwin-rebuild switch --flake github:nmasur/dotfiles#macbook + else + nixos-rebuild switch --flake github:nmasur/dotfiles + fi ''); }; From e011a1c6f1f3405080d078eb9153c257273ab7aa Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 10 Dec 2022 15:48:15 -0700 Subject: [PATCH 152/391] page readme app --- apps/readme.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/readme.nix b/apps/readme.nix index 034c639..9507513 100644 --- a/apps/readme.nix +++ b/apps/readme.nix @@ -3,7 +3,7 @@ type = "app"; program = builtins.toString (pkgs.writeShellScript "readme" '' - ${pkgs.glow}/bin/glow ${builtins.toString ../README.md} + ${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md} ''); } From adb7956213c829444ac8c90b72b33adfb99a33e5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 11 Dec 2022 09:52:32 -0700 Subject: [PATCH 153/391] fixes for python lsp --- templates/poetry/.flake8 | 2 + templates/poetry/flake.lock | 92 ------------------------------------- templates/python/.flake8 | 2 + templates/python/flake.lock | 92 ------------------------------------- 4 files changed, 4 insertions(+), 184 deletions(-) create mode 100644 templates/poetry/.flake8 delete mode 100644 templates/poetry/flake.lock create mode 100644 templates/python/.flake8 delete mode 100644 templates/python/flake.lock diff --git a/templates/poetry/.flake8 b/templates/poetry/.flake8 new file mode 100644 index 0000000..b366371 --- /dev/null +++ b/templates/poetry/.flake8 @@ -0,0 +1,2 @@ +max-line-length = 88 +extend-ignore = E203 diff --git a/templates/poetry/flake.lock b/templates/poetry/flake.lock deleted file mode 100644 index 2f87e83..0000000 --- a/templates/poetry/flake.lock +++ /dev/null @@ -1,92 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1653893745, - "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "locked": { - "lastModified": 1653893745, - "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1655779787, - "narHash": "sha256-Z5VL2AANN3Rk92xFs/3pPVyDQVTIcmNAIeTQNFOJnNE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ce83dc760cd3428ce9938aa711a0c7c81f55c567", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1655779787, - "narHash": "sha256-Z5VL2AANN3Rk92xFs/3pPVyDQVTIcmNAIeTQNFOJnNE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ce83dc760cd3428ce9938aa711a0c7c81f55c567", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "poetry2nix": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1655482677, - "narHash": "sha256-IGTwio1b4C7Etn4gBb76NILDS+8BsOmDlG8+dhfZL40=", - "owner": "nix-community", - "repo": "poetry2nix", - "rev": "ea3bd4eb70a3f9ead0dd88dab23e42c542e69c07", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "poetry2nix", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "poetry2nix": "poetry2nix" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/templates/python/.flake8 b/templates/python/.flake8 new file mode 100644 index 0000000..b366371 --- /dev/null +++ b/templates/python/.flake8 @@ -0,0 +1,2 @@ +max-line-length = 88 +extend-ignore = E203 diff --git a/templates/python/flake.lock b/templates/python/flake.lock deleted file mode 100644 index 1161aca..0000000 --- a/templates/python/flake.lock +++ /dev/null @@ -1,92 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "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" - } - }, - "mach-nix": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "pypi-deps-db": "pypi-deps-db" - }, - "locked": { - "lastModified": 1654084003, - "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=", - "owner": "DavHau", - "repo": "mach-nix", - "rev": "7e14360bde07dcae32e5e24f366c83272f52923f", - "type": "github" - }, - "original": { - "id": "mach-nix", - "ref": "3.5.0", - "type": "indirect" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1643805626, - "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-unstable", - "type": "indirect" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1656250965, - "narHash": "sha256-B5wj+k8uSe9YNijcTW7BHYAZzrzFQq5NMpmrnOGvxqo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9a17f325397d137ac4d219ecbd5c7f15154422f4", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "pypi-deps-db": { - "flake": false, - "locked": { - "lastModified": 1643877077, - "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", - "owner": "DavHau", - "repo": "pypi-deps-db", - "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", - "type": "github" - }, - "original": { - "owner": "DavHau", - "repo": "pypi-deps-db", - "type": "github" - } - }, - "root": { - "inputs": { - "mach-nix": "mach-nix", - "nixpkgs": "nixpkgs_2" - } - } - }, - "root": "root", - "version": 7 -} From d1b144f441adc7126c872f1875cd7953a3981afb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 13 Dec 2022 21:02:42 -0700 Subject: [PATCH 154/391] upgrade macos to ventura --- flake.lock | 84 +++++++++++++++++++-------------------- hosts/common.nix | 4 +- modules/darwin/system.nix | 2 +- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/flake.lock b/flake.lock index 50e5f9a..227cebd 100644 --- a/flake.lock +++ b/flake.lock @@ -90,11 +90,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1670280307, - "narHash": "sha256-3x+0whP1nCz5adQMIsBA3L9fI/ABOpRUJdbw0AmxBnU=", + "lastModified": 1670513770, + "narHash": "sha256-muL74fsbGA8K8WlZSPNWddOiuBnC54kAajncX6nXrh4=", "owner": "nix-community", "repo": "home-manager", - "rev": "2af0d07678fc15612345e0dd55337550dcf6465f", + "rev": "054d9e3187ca00479e8036dc0e92900a384f30fd", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1670273694, - "narHash": "sha256-Rb+AIMyncKNnP0EahDg5w37v6TXlGtd2SczugSQzMQU=", + "lastModified": 1670595719, + "narHash": "sha256-9jvA0QdcZtGWImiRZ8KRhXNsy5NxgZBm0TXtNLmFbyM=", "owner": "oxalica", "repo": "nil", - "rev": "101387fb2f54ebc67c894979d1ae0efac2b4ad5c", + "rev": "1c122ae707c6365ea731565daf307844df03e95e", "type": "github" }, "original": { @@ -265,11 +265,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1669809720, - "narHash": "sha256-RMT77f6CPOYtLLQ2esj+EJ1BPVWxf4RDidjrSvA5OhI=", + "lastModified": 1670559856, + "narHash": "sha256-xUkgQRFqE6HIFQXs9SIXMZiXcLaH2415UR6w/FnsgcY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "227de2b3bbec142f912c09d5e8a1b4e778aa54fb", + "rev": "6bc6f77cb171a74001033d94f17f49043a9f1804", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1670152712, - "narHash": "sha256-LJttwIvJqsZIj8u1LxVRv82vwUtkzVqQVi7Wb8gxPS4=", + "lastModified": 1670841420, + "narHash": "sha256-mSEia1FzrsHbfqjorMyYiX8NXdDVeR1Pw1k55jMJlJY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "14ddeaebcbe9a25748221d1d7ecdf98e20e2325e", + "rev": "33e0d99cbedf2acfd7340d2150837fbb28039a64", "type": "github" }, "original": { @@ -297,11 +297,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1667653703, - "narHash": "sha256-Xow4vx52/g5zkhlgZnMEm/TEXsj+13jTPCc2jIhW1xU=", + "lastModified": 1669418739, + "narHash": "sha256-T86oFvcUIRwHWBWUt7WjaP4BP/3lDGbv5AppQSI1FkI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f09ad462c5a121d0239fde645aacb2221553a217", + "rev": "695b3515251873e0a7e2021add4bba643c56cde3", "type": "github" }, "original": { @@ -313,11 +313,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1670247790, - "narHash": "sha256-fAqhpPJV53XmFQaJ7xnTOd+DKFLxGyfDnvSYW6ZOMQc=", + "lastModified": 1670864857, + "narHash": "sha256-YUHT88JLXHpbHg1IIze3QTJaT4zpdVgyCt3ojk9osk8=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "b3d2ebdb75cf1fa4290822b43dc31f61bd0023f8", + "rev": "623cc25016647eb62392aead7612f27d539c33de", "type": "github" }, "original": { @@ -328,11 +328,11 @@ }, "nur": { "locked": { - "lastModified": 1670315682, - "narHash": "sha256-/v0RgZZIjvsFuJbJLUlzRbzSlYFXq3olgJTuJBNtcoY=", + "lastModified": 1670905794, + "narHash": "sha256-wpg/ZYga8aDmUogB8YRK8KLiUsOLw0cnhJtaKutvKEk=", "owner": "nix-community", "repo": "nur", - "rev": "af814db16c89385c65e758608296440555f61ccc", + "rev": "a0869f532570fb0bbff84a158299c40c4af3fadd", "type": "github" }, "original": { @@ -344,11 +344,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1670318621, - "narHash": "sha256-cySTYqdmOktCmwC0mh6gJoGYzyfrOVqNtUBOV5RBSCw=", + "lastModified": 1670933229, + "narHash": "sha256-qnU1Uq858bAVRYjEvVwqRDzAbCM2XkV2+GuaPuLMElY=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "8faa599646f482d3ed04e645eb04af94bcd12feb", + "rev": "cbf8762f15fac03a51eaa2c6f983d4a5045c95b4", "type": "github" }, "original": { @@ -360,11 +360,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1670039798, - "narHash": "sha256-mQfo9KlNHbZtDIO3U8BZ7PGVBP5EtLUDpETq+bfqpVU=", + "lastModified": 1670847281, + "narHash": "sha256-vHCbR3f5LYJLYk0vNVoELSR4ZAH7YIavdCIuenRLdas=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "f8489c992998e1e1b45aec65bdb9615e5cd59a61", + "rev": "0cd8ac4751c39440a1c28c6be4704f3597807d29", "type": "github" }, "original": { @@ -376,11 +376,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1670321697, - "narHash": "sha256-lL9cPP7t852Zst1n0nWDp1r31Sx17T+xAiJvIylh4vo=", + "lastModified": 1670914677, + "narHash": "sha256-ku6oYE8gXPB91H3o3U/8608obXyiiJV25JbAdwdR/uE=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "7eb553ce4dc9af6631a823b5e4b5aa33fdc45bfd", + "rev": "eadfcad580edc74b258dc1380f1e3edea35cc6d4", "type": "github" }, "original": { @@ -425,11 +425,11 @@ ] }, "locked": { - "lastModified": 1669775522, - "narHash": "sha256-6xxGArBqssX38DdHpDoPcPvB/e79uXyQBwpBcaO/BwY=", + "lastModified": 1670552927, + "narHash": "sha256-lCE51eAGrAFS4k9W5aDGFpVtOAwQQ/rFMN80PCDh0vo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "3158e47f6b85a288d12948aeb9a048e0ed4434d6", + "rev": "a0fdafd18c9cf599fde17fbaf07dbb20fa57eecb", "type": "github" }, "original": { @@ -473,11 +473,11 @@ "toggleterm-nvim-src": { "flake": false, "locked": { - "lastModified": 1667475764, - "narHash": "sha256-gazqaTsK5hAFqk6OONqTsR/zmjN3P8fPKsYufBhkeRA=", + "lastModified": 1670593071, + "narHash": "sha256-0n3WbUM3rYyR2BXgeyYuyTZIbIs5dzuIu8imsSvAc8U=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "3ba683827c623affb4d9aa518e97b34db2623093", + "rev": "b02a1674bd0010d7982b056fd3df4f717ff8a57a", "type": "github" }, "original": { @@ -524,11 +524,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1669863592, - "narHash": "sha256-g0YVtM5Hi8k27yIWvPR7ZRRE1JscL6XtC5dv9Li1tMM=", + "lastModified": 1670775588, + "narHash": "sha256-TCfA98qfZhBj0SN9RN23l/tuz82KwGHH7r2axkjQZig=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "522219248de4b5876f18e47f34d979dd9f4fcbdc", + "rev": "3721fe7c056e18c4ded6c405dbee719692a4528a", "type": "github" }, "original": { diff --git a/hosts/common.nix b/hosts/common.nix index a28916a..16eb8e2 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -3,7 +3,7 @@ imports = [ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ]; - options = rec { + options = { user = lib.mkOption { type = lib.types.str; description = "Primary user of the system"; @@ -74,7 +74,7 @@ }; }; - config = let stateVersion = "22.11"; + config = let stateVersion = "23.05"; in { # Enable features in Nix commands diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 0294446..a9083c6 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -174,7 +174,7 @@ "$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \ "$(__dock_item /Applications/Obsidian.app)" \ "$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \ - "$(__dock_item /System/Applications/System\ Preferences.app)" + "$(__dock_item /System/Applications/System\ Settings.app)" ''; }; From a0c99a84498a2575979732d66d14150a1e7892f0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 18 Dec 2022 17:24:44 -0700 Subject: [PATCH 155/391] fix: remove print crowding the hammerspoon log --- modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua index 7b4d676..df6c769 100644 --- a/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua @@ -69,7 +69,7 @@ function obj:init() -- If any other key is pressed, don't send escape self.asModifier = hs.eventtap.new({ hs.eventtap.event.types.keyDown }, function(_) self.sendEscape = false - print("Don't sent escape") + -- print("Don't sent escape") end) -- If mouse is moving significantly, don't send escape From 50acdd0c58a22a02213af037ce3da6e56a6c2d56 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 18 Dec 2022 17:25:34 -0700 Subject: [PATCH 156/391] update packages --- flake.lock | 79 +++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/flake.lock b/flake.lock index 227cebd..687ea1d 100644 --- a/flake.lock +++ b/flake.lock @@ -55,11 +55,11 @@ ] }, "locked": { - "lastModified": 1668784520, - "narHash": "sha256-gGgVAMwYPPmrfnvnoRi6OkEB5KRsNTb9uYzEceLdO/g=", + "lastModified": 1671196037, + "narHash": "sha256-2+J98SeczFWonbqFLMEAQC7vZEe6I2gM17XYvEmG52I=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "6349b99bc2b96ded34d068a88c7c5ced406b7f7f", + "rev": "adb8ac0453c8b2c40f5bffb578453dbaee838952", "type": "github" }, "original": { @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1670028550, - "narHash": "sha256-jrCEzbRfcNBSy0YHYPLpMSeoluryej3EuqdMZsR1bhQ=", + "lastModified": 1671410692, + "narHash": "sha256-azBs+c7zMnjNXntsnFM67AKsTdlUhU4eFzZwtTEGScs=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "8f3697c4ea0b138255a30b65510a25d393c4ce4c", + "rev": "ce6bde60382284ca3044b4010143fec0c44a3cf5", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1670513770, - "narHash": "sha256-muL74fsbGA8K8WlZSPNWddOiuBnC54kAajncX6nXrh4=", + "lastModified": 1671335968, + "narHash": "sha256-V7mjlh7brp70elokmml6XzHinpTilkQJjiYIGjEmSGs=", "owner": "nix-community", "repo": "home-manager", - "rev": "054d9e3187ca00479e8036dc0e92900a384f30fd", + "rev": "37713c6b04b963d41664e03576f73a18c9b0d224", "type": "github" }, "original": { @@ -234,11 +234,11 @@ ] }, "locked": { - "lastModified": 1669065280, - "narHash": "sha256-3+pq1oJWjGDLfd8G/vR3IIFZ+EQ/aglukA0bTiMlf3o=", + "lastModified": 1671355134, + "narHash": "sha256-ZtnUWTDDyFog+NQBjZpnhgPdj3gHp5ImxFVWy+ObNno=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "50aeec40f2072d2ab267c8ec8a345573704ec110", + "rev": "64a96ca8621d03cb3889daf0d3ff58d8209e3e0c", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1670841420, - "narHash": "sha256-mSEia1FzrsHbfqjorMyYiX8NXdDVeR1Pw1k55jMJlJY=", + "lastModified": 1671271357, + "narHash": "sha256-xRJdLbWK4v2SewmSStYrcLa0YGJpleufl44A19XSW8k=", "owner": "nixos", "repo": "nixpkgs", - "rev": "33e0d99cbedf2acfd7340d2150837fbb28039a64", + "rev": "40f79f003b6377bd2f4ed4027dde1f8f922995dd", "type": "github" }, "original": { @@ -297,27 +297,28 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1669418739, - "narHash": "sha256-T86oFvcUIRwHWBWUt7WjaP4BP/3lDGbv5AppQSI1FkI=", + "lastModified": 1671313200, + "narHash": "sha256-itZTrtHeDJjV696+ur0/TzkTqb5y3Eb57WRLRPK3rwA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "695b3515251873e0a7e2021add4bba643c56cde3", + "rev": "0938d73bb143f4ae037143572f11f4338c7b2d1c", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "nixos-22.05", - "type": "indirect" + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" } }, "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1670864857, - "narHash": "sha256-YUHT88JLXHpbHg1IIze3QTJaT4zpdVgyCt3ojk9osk8=", + "lastModified": 1671402461, + "narHash": "sha256-6wC+bmgTf+oP7sCdJhO5xs+hwf7mcsrA9G7Q8lraTRc=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "623cc25016647eb62392aead7612f27d539c33de", + "rev": "f1182c2d3748da7c94f5288f8054741f26f0cf3b", "type": "github" }, "original": { @@ -328,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1670905794, - "narHash": "sha256-wpg/ZYga8aDmUogB8YRK8KLiUsOLw0cnhJtaKutvKEk=", + "lastModified": 1671421536, + "narHash": "sha256-adBNEHWgzjZblMorByLE+xkJIj3r+cutYzCTtF/8ftY=", "owner": "nix-community", "repo": "nur", - "rev": "a0869f532570fb0bbff84a158299c40c4af3fadd", + "rev": "b08acb253b4f50eceb42908bc44a445ae2fed272", "type": "github" }, "original": { @@ -344,11 +345,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1670933229, - "narHash": "sha256-qnU1Uq858bAVRYjEvVwqRDzAbCM2XkV2+GuaPuLMElY=", + "lastModified": 1671346073, + "narHash": "sha256-sIzxI7Xk5PeCcCOfQff5FXhY9niHa5A1Ka5RdTQSQjM=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "cbf8762f15fac03a51eaa2c6f983d4a5045c95b4", + "rev": "973aa14d0992df82ff82f714d978a3eb8d676600", "type": "github" }, "original": { @@ -360,11 +361,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1670847281, - "narHash": "sha256-vHCbR3f5LYJLYk0vNVoELSR4ZAH7YIavdCIuenRLdas=", + "lastModified": 1671423072, + "narHash": "sha256-AI2ErDw1wKpZcShjA8S9D9oQOHPUF8VAj0npLNIZPZ8=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "0cd8ac4751c39440a1c28c6be4704f3597807d29", + "rev": "547db6e9297ca9b0da95965d1760461b33b44687", "type": "github" }, "original": { @@ -376,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1670914677, - "narHash": "sha256-ku6oYE8gXPB91H3o3U/8608obXyiiJV25JbAdwdR/uE=", + "lastModified": 1671400998, + "narHash": "sha256-mlbZ5vQGXNXWkFc5YoLrRpVzKa9EVB8QW0mwN/t94CY=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "eadfcad580edc74b258dc1380f1e3edea35cc6d4", + "rev": "a75aded7aeba98a89d018f9a6ae0cad9dfbe7c2b", "type": "github" }, "original": { @@ -524,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1670775588, - "narHash": "sha256-TCfA98qfZhBj0SN9RN23l/tuz82KwGHH7r2axkjQZig=", + "lastModified": 1671143316, + "narHash": "sha256-yhX73D3iTfAmf1gaVBWAOpyaoXrwWRDm+72ivYW0S68=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "3721fe7c056e18c4ded6c405dbee719692a4528a", + "rev": "fab2833c091e059fd75e0c2cd570279500e76351", "type": "github" }, "original": { From 1b3245795636aecdcd757b1ce982e83d896df54d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:22:24 -0700 Subject: [PATCH 157/391] fix: update dock for hammerspoon shortcuts --- modules/darwin/hammerspoon.nix | 17 +++++++++++++++-- .../hammerspoon/Spoons/Launcher.spoon/init.lua | 6 +++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix index e0261cb..caf56b4 100644 --- a/modules/darwin/hammerspoon.nix +++ b/modules/darwin/hammerspoon.nix @@ -1,9 +1,22 @@ -{ config, ... }: { +{ config, pkgs, ... }: { # Hammerspoon - MacOS custom automation scripting home-manager.users.${config.user} = { - xdg.configFile.hammerspoon = { source = ./hammerspoon; }; + xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua; + xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source = + ./hammerspoon/Spoons/ControlEscape.spoon; + xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = + ./hammerspoon/Spoons/DismissAlerts.spoon; + xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = + pkgs.substituteAll { + src = ./hammerspoon/Spoons/Launcher.spoon/init.lua; + firefox = "${pkgs.firefox-bin}/Applications/Firefox.app"; + discord = "${pkgs.discord}/Applications/Discord.app"; + kitty = "${pkgs.kitty}/Applications/kitty.app"; + }; + xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = + ./hammerspoon/Spoons/MoveWindow.spoon; }; homebrew.casks = [ "hammerspoon" ]; diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua index 2be1b5a..971b3c8 100644 --- a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua @@ -56,13 +56,13 @@ function obj:init() -- Launcher shortcuts self.launcher:bind("ctrl", "space", function() end) self.launcher:bind("", "return", function() - self:switch("kitty.app") + self:switch("@kitty@") end) self.launcher:bind("", "C", function() self:switch("Calendar.app") end) self.launcher:bind("", "D", function() - self:switch("Discord.app") + self:switch("@discord@") end) self.launcher:bind("", "E", function() self:switch("Mail.app") @@ -71,7 +71,7 @@ function obj:init() self:switch("Music.app") end) self.launcher:bind("", "F", function() - self:switch("Firefox.app") + self:switch("@firefox@") end) self.launcher:bind("", "H", function() self:switch("Hammerspoon.app") From fd7c523ebdb9a1a5eba85af051d05310bad756c5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:22:41 -0700 Subject: [PATCH 158/391] try to disable splash screen when updating firefox --- modules/applications/firefox.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 389b3a1..9d8d569 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -44,6 +44,8 @@ "browser.toolbars.bookmarks.visibility" = "newtab"; "browser.startup.page" = 3; # Restore previous session "browser.newtabpage.enabled" = false; # Make new tabs blank + "trailhead.firstrun.didSeeAboutWelcome" = + true; # Disable welcome splash "dom.forms.autocomplete.formautofill" = false; # Disable autofill "extensions.formautofill.creditCards.enabled" = false; # Disable credit cards From bf1d2f1e9ec707f5c575c7c590328b53c4036304 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:23:00 -0700 Subject: [PATCH 159/391] update lockfile --- flake.lock | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index 687ea1d..8bf9e60 100644 --- a/flake.lock +++ b/flake.lock @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1671335968, - "narHash": "sha256-V7mjlh7brp70elokmml6XzHinpTilkQJjiYIGjEmSGs=", + "lastModified": 1671459164, + "narHash": "sha256-RbkDnvLV7WjbiF4Dpiezrf8kXxwieQXAVtY8ciRQj6Q=", "owner": "nix-community", "repo": "home-manager", - "rev": "37713c6b04b963d41664e03576f73a18c9b0d224", + "rev": "e7eba9cc46547ae86642ad3c6a9a4fb22c07bc26", "type": "github" }, "original": { @@ -198,11 +198,11 @@ ] }, "locked": { - "lastModified": 1666021730, - "narHash": "sha256-eXd9bqYleh+BZsUybKCj7rNhnwoV0tzsuGGXKmW/+NA=", + "lastModified": 1671522211, + "narHash": "sha256-i5BLrj3wlIC1VMQTfBSYIasEmv3D4as0Mu2K3rdJrSU=", "owner": "gytis-ivaskevicius", "repo": "nix2vim", - "rev": "f3b56da72278cd720fe7fb4b6d001047b7179669", + "rev": "3cc95ef557b6e2f97f5ff14ae89997a564d3a130", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1671271357, - "narHash": "sha256-xRJdLbWK4v2SewmSStYrcLa0YGJpleufl44A19XSW8k=", + "lastModified": 1671359686, + "narHash": "sha256-3MpC6yZo+Xn9cPordGz2/ii6IJpP2n8LE8e/ebUXLrs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "40f79f003b6377bd2f4ed4027dde1f8f922995dd", + "rev": "04f574a1c0fde90b51bf68198e2297ca4e7cccf4", "type": "github" }, "original": { @@ -314,11 +314,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1671402461, - "narHash": "sha256-6wC+bmgTf+oP7sCdJhO5xs+hwf7mcsrA9G7Q8lraTRc=", + "lastModified": 1671458255, + "narHash": "sha256-YQaWKSW9D1HEBva9GeivQkylFeYfTrFUiTkXYF4V8SA=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "f1182c2d3748da7c94f5288f8054741f26f0cf3b", + "rev": "db1c7cb5f6d6f6036b7f8433bb3cfcbe985cb3d1", "type": "github" }, "original": { @@ -329,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1671421536, - "narHash": "sha256-adBNEHWgzjZblMorByLE+xkJIj3r+cutYzCTtF/8ftY=", + "lastModified": 1671547500, + "narHash": "sha256-97hzIBBNDbva9eRj1WomM+pimxt7hVrH/yNjUfJSMJc=", "owner": "nix-community", "repo": "nur", - "rev": "b08acb253b4f50eceb42908bc44a445ae2fed272", + "rev": "4103fbdf825891b4dc54a6bda72ef1757081444c", "type": "github" }, "original": { @@ -345,11 +345,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1671346073, - "narHash": "sha256-sIzxI7Xk5PeCcCOfQff5FXhY9niHa5A1Ka5RdTQSQjM=", + "lastModified": 1671517641, + "narHash": "sha256-RWXc/nCVNPv0BQN99QQMfeplQFpEsNJdmyoC/TQuIYQ=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "973aa14d0992df82ff82f714d978a3eb8d676600", + "rev": "d597b0f3605f43526f1b6948c6d7ca2919ea32ac", "type": "github" }, "original": { @@ -361,11 +361,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1671423072, - "narHash": "sha256-AI2ErDw1wKpZcShjA8S9D9oQOHPUF8VAj0npLNIZPZ8=", + "lastModified": 1671430707, + "narHash": "sha256-SdQ7nCgrtSN96XeaPjDoGnc++jllYy/up/jDc5LunRM=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "547db6e9297ca9b0da95965d1760461b33b44687", + "rev": "e14c2895b4f36a22001f7773244041c173dcf867", "type": "github" }, "original": { @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1671400998, - "narHash": "sha256-mlbZ5vQGXNXWkFc5YoLrRpVzKa9EVB8QW0mwN/t94CY=", + "lastModified": 1671521720, + "narHash": "sha256-GeuRomX3cFXK/zqWf1SJ3WXbTSLLy3FT99lIyhVnefo=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "a75aded7aeba98a89d018f9a6ae0cad9dfbe7c2b", + "rev": "eedb7b9c69b13afe86461b0742266bb62b811ece", "type": "github" }, "original": { @@ -525,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1671143316, - "narHash": "sha256-yhX73D3iTfAmf1gaVBWAOpyaoXrwWRDm+72ivYW0S68=", + "lastModified": 1671480147, + "narHash": "sha256-IzWdZL8jMNtyKsXXJjn2L4MsBeR52WBdhciPw4latHU=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "fab2833c091e059fd75e0c2cd570279500e76351", + "rev": "577d7919e4380e6905e69d4a5f8f48a41ca37187", "type": "github" }, "original": { From d040077d3a49db10cef9da281c5ac969d7833750 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 21 Dec 2022 14:18:03 -0700 Subject: [PATCH 160/391] convert to proper module layout --- apps/default.nix | 5 +- .../everforest/default.nix | 0 .../gruvbox/default.nix | 0 .../gruvbox/neovim-gruvbox.nix | 0 .../nord/default.nix | 0 .../nord/neovim.lua | 0 flake.nix | 7 +- hosts/desktop/default.nix | 39 +-- hosts/macbook/default.nix | 33 +- hosts/oracle/default.nix | 33 +- hosts/wsl/default.nix | 16 +- modules/applications/1password.nix | 18 +- modules/applications/alacritty.nix | 11 +- modules/applications/calibre.nix | 11 +- modules/applications/discord.nix | 11 +- modules/applications/firefox.nix | 21 +- modules/applications/kitty.nix | 11 +- modules/applications/media.nix | 11 +- modules/applications/nautilus.nix | 11 +- modules/applications/obsidian.nix | 11 +- modules/applications/qbittorrent.nix | 11 +- modules/colorscheme/gruvbox/neovim.lua | 13 - modules/darwin/alacritty.nix | 2 +- modules/darwin/fonts.nix | 4 +- modules/darwin/hammerspoon.nix | 48 +-- modules/darwin/homebrew.nix | 89 ++--- modules/darwin/kitty.nix | 2 +- modules/darwin/networking.nix | 12 +- modules/darwin/nixpkgs.nix | 2 +- modules/darwin/system.nix | 308 +++++++++--------- modules/darwin/tmux.nix | 6 +- modules/darwin/user.nix | 22 +- modules/darwin/utilities.nix | 2 +- hosts/common.nix => modules/default.nix | 19 +- modules/gaming/default.nix | 14 +- modules/gaming/leagueoflegends.nix | 38 ++- modules/gaming/legendary.nix | 5 +- modules/gaming/lutris.nix | 4 +- modules/gaming/minecraft-server.nix | 243 +++++++------- modules/gaming/steam.nix | 4 +- modules/graphical/dmenu.nix | 4 +- modules/graphical/fonts.nix | 2 +- modules/graphical/i3.nix | 2 +- modules/graphical/picom.nix | 4 +- modules/graphical/polybar.nix | 2 +- modules/graphical/rofi.nix | 2 +- modules/graphical/xorg.nix | 4 +- modules/hardware/audio.nix | 2 +- modules/hardware/boot.nix | 4 +- modules/hardware/default.nix | 7 +- modules/hardware/monitors.nix | 85 ++--- modules/hardware/mouse.nix | 27 +- modules/hardware/networking.nix | 18 +- modules/hardware/server.nix | 12 +- modules/hardware/sleep.nix | 14 +- modules/hardware/wifi.nix | 14 +- modules/mail/aerc.nix | 6 +- modules/mail/default.nix | 10 +- modules/mail/himalaya.nix | 6 +- modules/neovim/default.nix | 43 +-- modules/nixos/default.nix | 12 +- modules/nixos/doas.nix | 43 +-- modules/nixos/timezone.nix | 24 +- modules/nixos/user.nix | 4 +- modules/programming/default.nix | 12 + modules/programming/haskell.nix | 16 +- modules/programming/kubernetes.nix | 241 +++++++------- modules/programming/lua.nix | 14 +- modules/programming/nix.nix | 18 +- modules/programming/python.nix | 24 +- modules/programming/terraform.nix | 26 +- modules/repositories/default.nix | 5 + modules/repositories/dotfiles.nix | 34 +- modules/services/backups.nix | 7 +- modules/services/caddy.nix | 12 +- modules/services/calibre.nix | 7 +- modules/services/cloudflare.nix | 8 +- modules/services/default.nix | 25 ++ modules/services/gitea.nix | 7 +- modules/services/gnupg.nix | 4 +- modules/services/honeypot.nix | 6 +- modules/services/jellyfin.nix | 5 +- modules/services/keybase.nix | 48 +-- modules/services/mullvad.nix | 12 +- modules/services/n8n.nix | 40 ++- modules/services/netdata.nix | 4 +- modules/services/nextcloud.nix | 7 +- modules/services/prometheus.nix | 5 +- modules/services/secrets.nix | 2 +- modules/services/sshd.nix | 2 +- modules/services/transmission.nix | 5 +- modules/services/vaultwarden.nix | 5 +- modules/services/wireguard.nix | 4 +- modules/shell/charm.nix | 6 +- modules/wsl/default.nix | 32 +- 95 files changed, 1196 insertions(+), 895 deletions(-) rename {modules/colorscheme => colorscheme}/everforest/default.nix (100%) rename {modules/colorscheme => colorscheme}/gruvbox/default.nix (100%) rename {modules/colorscheme => colorscheme}/gruvbox/neovim-gruvbox.nix (100%) rename {modules/colorscheme => colorscheme}/nord/default.nix (100%) rename {modules/colorscheme => colorscheme}/nord/neovim.lua (100%) delete mode 100644 modules/colorscheme/gruvbox/neovim.lua rename hosts/common.nix => modules/default.nix (92%) create mode 100644 modules/programming/default.nix create mode 100644 modules/repositories/default.nix create mode 100644 modules/services/default.nix diff --git a/apps/default.nix b/apps/default.nix index 6c977d0..aa13880 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -59,9 +59,8 @@ program = "${ (import ../modules/neovim/package { inherit pkgs; - colors = import ../modules/colorscheme/gruvbox/neovim-gruvbox.nix { - inherit pkgs; - }; + colors = + import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; }; }) }/bin/nvim"; }; diff --git a/modules/colorscheme/everforest/default.nix b/colorscheme/everforest/default.nix similarity index 100% rename from modules/colorscheme/everforest/default.nix rename to colorscheme/everforest/default.nix diff --git a/modules/colorscheme/gruvbox/default.nix b/colorscheme/gruvbox/default.nix similarity index 100% rename from modules/colorscheme/gruvbox/default.nix rename to colorscheme/gruvbox/default.nix diff --git a/modules/colorscheme/gruvbox/neovim-gruvbox.nix b/colorscheme/gruvbox/neovim-gruvbox.nix similarity index 100% rename from modules/colorscheme/gruvbox/neovim-gruvbox.nix rename to colorscheme/gruvbox/neovim-gruvbox.nix diff --git a/modules/colorscheme/nord/default.nix b/colorscheme/nord/default.nix similarity index 100% rename from modules/colorscheme/nord/default.nix rename to colorscheme/nord/default.nix diff --git a/modules/colorscheme/nord/neovim.lua b/colorscheme/nord/neovim.lua similarity index 100% rename from modules/colorscheme/nord/neovim.lua rename to colorscheme/nord/neovim.lua diff --git a/flake.nix b/flake.nix index ef16b31..8eff23d 100644 --- a/flake.nix +++ b/flake.nix @@ -104,7 +104,7 @@ fullName = "Noah Masur"; gitName = fullName; gitEmail = "7386960+nmasur@users.noreply.github.com"; - mailServer = "noahmasur.com"; + mail.server = "noahmasur.com"; dotfilesRepo = "git@github.com:nmasur/dotfiles"; }; @@ -154,9 +154,8 @@ neovim = let pkgs = import nixpkgs { inherit system overlays; }; in import ./modules/neovim/package { inherit pkgs; - colors = import ./modules/colorscheme/gruvbox/neovim-gruvbox.nix { - inherit pkgs; - }; + colors = + import ./colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; }; }; }); diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 89d134c..c2ece6d 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -10,6 +10,7 @@ nixpkgs.lib.nixosSystem { globals home-manager.nixosModules.home-manager { + physical = true; networking.hostName = "desktop"; nixpkgs.overlays = [ nur.overlay ]; # Set registry to flake packages, used for nix X commands @@ -17,32 +18,32 @@ nixpkgs.lib.nixosSystem { identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = true; theme = { - colors = (import ../../modules/colorscheme/gruvbox).dark; + colors = (import ../../colorscheme/gruvbox).dark; dark = true; }; wallpaper = "${wallpapers}/gruvbox/road.jpg"; gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; + + media.enable = true; + firefox.enable = true; + kitty.enable = true; + "1password".enable = true; + discord.enable = true; + nautilus.enable = true; + obsidian.enable = true; + mail.aerc.enable = true; + mail.himalaya.enable = true; + gaming.enable = true; + gaming.steam.enable = true; + gaming.legendary.enable = true; + keybase.enable = true; + mullvad.enable = true; + nixlang.enable = true; + dotfiles.enable = true; } ./hardware-configuration.nix - ../common.nix - ../../modules/hardware - ../../modules/nixos - ../../modules/graphical - ../../modules/applications/media.nix - ../../modules/applications/firefox.nix - ../../modules/applications/kitty.nix - ../../modules/applications/1password.nix - ../../modules/applications/discord.nix - ../../modules/applications/nautilus.nix - ../../modules/applications/obsidian.nix - ../../modules/mail - ../../modules/gaming/steam.nix - ../../modules/gaming/legendary.nix - ../../modules/repositories/notes.nix - ../../modules/services/keybase.nix - ../../modules/services/mullvad.nix - ../../modules/programming/nix.nix + ../../modules ]; } diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index d350cc6..cd5d2da 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -7,6 +7,7 @@ darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs = { }; modules = [ + ../../modules (globals // { user = "Noah.Masur"; gitName = "Noah-Masur_1701"; @@ -14,30 +15,30 @@ darwin.lib.darwinSystem { }) home-manager.darwinModules.home-manager { + networking.hostName = "noah-masur-mac"; identityFile = "/Users/Noah.Masur/.ssh/id_ed25519"; gui.enable = true; theme = { - colors = (import ../../modules/colorscheme/gruvbox).dark; + colors = (import ../../colorscheme/gruvbox).dark; dark = true; }; - mailUser = globals.user; - networking.hostName = "noah-masur-mac"; + mail.user = globals.user; nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; + + mail.aerc.enable = true; + mail.himalaya.enable = true; + kitty.enable = true; + discord.enable = true; + firefox.enable = true; + dotfiles.enable = true; + nixlang.enable = true; + terraform.enable = true; + python.enable = true; + lua.enable = true; + kubernetes.enable = true; + "1password".enable = true; } - ../common.nix - ../../modules/darwin - ../../modules/mail - ../../modules/applications/alacritty.nix - ../../modules/applications/kitty.nix - ../../modules/applications/discord.nix - ../../modules/applications/firefox.nix - ../../modules/repositories/notes.nix - ../../modules/programming/nix.nix - ../../modules/programming/terraform.nix - ../../modules/programming/python.nix - ../../modules/programming/lua.nix - ../../modules/programming/kubernetes.nix ]; } diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 8bdbd64..265b03e 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -11,11 +11,14 @@ nixpkgs.lib.nixosSystem { system = "aarch64-linux"; specialArgs = { }; modules = [ - (removeAttrs globals [ "mailServer" ]) + ./hardware-configuration.nix + ../../modules + (removeAttrs globals [ "mail.server" ]) home-manager.nixosModules.home-manager { + server = true; gui.enable = false; - theme = { colors = (import ../../modules/colorscheme/gruvbox).dark; }; + theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; # FQDNs for various services @@ -33,7 +36,7 @@ nixpkgs.lib.nixosSystem { "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; # Nextcloud backup config - backupS3 = { + backup.s3 = { endpoint = "s3.us-west-002.backblazeb2.com"; bucket = "noahmasur-backup"; accessKeyId = "0026b0e73b2e2c80000000005"; @@ -72,20 +75,16 @@ nixpkgs.lib.nixosSystem { # Grant access to Transmission directories from Jellyfin users.users.jellyfin.extraGroups = [ "transmission" ]; + + # Proxy traffic with Cloudflare + cloudflare.enable = true; + + # Setup Minecraft server + gaming.minecraft-server.enable = true; + + # Clone dotfiles + dotfiles.enable = true; + } - ./hardware-configuration.nix - ../common.nix - ../../modules/nixos - ../../modules/hardware/server.nix - ../../modules/services/sshd.nix - ../../modules/services/calibre.nix - ../../modules/services/jellyfin.nix - ../../modules/services/nextcloud.nix - ../../modules/services/cloudflare.nix - ../../modules/services/transmission.nix - ../../modules/services/prometheus.nix - ../../modules/services/vaultwarden.nix - ../../modules/services/gitea.nix - ../../modules/gaming/minecraft-server.nix ]; } diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index 3c428c4..b9b8250 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -10,6 +10,7 @@ nixpkgs.lib.nixosSystem { globals wsl.nixosModules.wsl home-manager.nixosModules.home-manager + ../../modules { networking.hostName = "wsl"; # Set registry to flake packages, used for nix X commands @@ -17,7 +18,7 @@ nixpkgs.lib.nixosSystem { identityFile = "/home/${globals.user}/.ssh/id_ed25519"; gui.enable = false; theme = { - colors = (import ../../modules/colorscheme/gruvbox).dark; + colors = (import ../../colorscheme/gruvbox).dark; dark = true; }; passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; @@ -30,13 +31,12 @@ nixpkgs.lib.nixosSystem { interop.includePath = false; # Including Windows PATH will slow down Neovim command mode }; + + mail.aerc.enable = true; + mail.himalaya.enable = true; + dotfiles.enable = true; + nixlang.enable = true; + lua.enable = true; } - ../common.nix - ../../modules/wsl - ../../modules/nixos - ../../modules/mail - ../../modules/repositories/notes.nix - ../../modules/programming/nix.nix - ../../modules/programming/lua.nix ]; } diff --git a/modules/applications/1password.nix b/modules/applications/1password.nix index e57f90b..9a31c03 100644 --- a/modules/applications/1password.nix +++ b/modules/applications/1password.nix @@ -1,10 +1,20 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { - unfreePackages = [ "1password" "_1password-gui" ]; - home-manager.users.${config.user} = { - home.packages = with pkgs; [ _1password-gui ]; + options = { + "1password" = { + enable = lib.mkEnableOption { + description = "Enable 1Password."; + default = false; + }; }; }; + config = lib.mkIf + (config.gui.enable && config."1password".enable && pkgs.stdenv.isLinux) { + unfreePackages = [ "1password" "_1password-gui" ]; + home-manager.users.${config.user} = { + home.packages = with pkgs; [ _1password-gui ]; + }; + }; + } diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index ab6302e..e5e5310 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + alacritty = { + enable = lib.mkEnableOption { + description = "Enable Alacritty."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.alacritty.enable) { home-manager.users.${config.user} = { xsession.windowManager.i3.config.terminal = "alacritty"; programs.rofi.terminal = "${pkgs.alacritty}/bin/alacritty"; diff --git a/modules/applications/calibre.nix b/modules/applications/calibre.nix index 09e643a..1a65f0f 100644 --- a/modules/applications/calibre.nix +++ b/modules/applications/calibre.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + calibre = { + enable = lib.mkEnableOption { + description = "Enable Calibre."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.calibre.enable) { home-manager.users.${config.user} = { home.packages = with pkgs; [ calibre ]; # home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; }; diff --git a/modules/applications/discord.nix b/modules/applications/discord.nix index 91d7783..444967c 100644 --- a/modules/applications/discord.nix +++ b/modules/applications/discord.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + discord = { + enable = lib.mkEnableOption { + description = "Enable Discord."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.discord.enable) { unfreePackages = [ "discord" ]; home-manager.users.${config.user} = { home.packages = with pkgs; [ discord ]; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 9d8d569..537181d 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -1,13 +1,26 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { - unfreePackages = [ "onepassword-password-manager" "okta-browser-plugin" ]; + options = { + firefox = { + enable = lib.mkEnableOption { + description = "Enable Firefox."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.firefox.enable) { + + unfreePackages = [ + (lib.mkIf config."1password".enable "onepassword-password-manager") + "okta-browser-plugin" + ]; home-manager.users.${config.user} = { - programs.firefox = rec { + programs.firefox = { enable = true; package = if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox; @@ -17,7 +30,7 @@ multi-account-containers facebook-container temporary-containers - onepassword-password-manager + (lib.mkIf config."1password".enable onepassword-password-manager) okta-browser-plugin sponsorblock reddit-enhancement-suite diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index dd4d727..8de7236 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + kitty = { + enable = lib.mkEnableOption { + description = "Enable Kitty."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.kitty.enable) { home-manager.users.${config.user} = { # xsession.windowManager.i3.config.terminal = "kitty"; # programs.rofi.terminal = "${pkgs.kitty}/bin/kitty"; diff --git a/modules/applications/media.nix b/modules/applications/media.nix index c7e69a4..c2a1620 100644 --- a/modules/applications/media.nix +++ b/modules/applications/media.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + media = { + enable = lib.mkEnableOption { + description = "Enable media programs."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.media.enable) { home-manager.users.${config.user}.home.packages = with pkgs; [ mpv # Video viewer sxiv # Image viewer diff --git a/modules/applications/nautilus.nix b/modules/applications/nautilus.nix index 7406a4c..3c81b0b 100644 --- a/modules/applications/nautilus.nix +++ b/modules/applications/nautilus.nix @@ -1,7 +1,16 @@ { config, pkgs, lib, ... }: { + options = { + nautilus = { + enable = lib.mkEnableOption { + description = "Enable Nautilus file manager."; + default = false; + }; + }; + }; + # Install Nautilus file manager - config = lib.mkIf config.gui.enable { + config = lib.mkIf (config.gui.enable && config.nautilus.enable) { home-manager.users.${config.user} = { home.packages = with pkgs; [ gnome.nautilus diff --git a/modules/applications/obsidian.nix b/modules/applications/obsidian.nix index 7f18e12..6a35f6b 100644 --- a/modules/applications/obsidian.nix +++ b/modules/applications/obsidian.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + obsidian = { + enable = lib.mkEnableOption { + description = "Enable Obsidian."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.obsidian.enable) { unfreePackages = [ "obsidian" ]; home-manager.users.${config.user} = { home.packages = with pkgs; [ obsidian ]; diff --git a/modules/applications/qbittorrent.nix b/modules/applications/qbittorrent.nix index 4447bb8..9750648 100644 --- a/modules/applications/qbittorrent.nix +++ b/modules/applications/qbittorrent.nix @@ -1,6 +1,15 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + options = { + qbittorrent = { + enable = lib.mkEnableOption { + description = "Enable qBittorrent."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.qbittorrent.enable) { home-manager.users.${config.user} = { diff --git a/modules/colorscheme/gruvbox/neovim.lua b/modules/colorscheme/gruvbox/neovim.lua deleted file mode 100644 index 086b0cb..0000000 --- a/modules/colorscheme/gruvbox/neovim.lua +++ /dev/null @@ -1,13 +0,0 @@ -local M = {} - -M.packer = function(use) - use({ - "lifepillar/vim-gruvbox8", - config = function() - vim.g.gruvbox_italicize_strings = 0 - vim.cmd("colorscheme gruvbox8") - end, - }) -end - -return M diff --git a/modules/darwin/alacritty.nix b/modules/darwin/alacritty.nix index 2100727..0dcab47 100644 --- a/modules/darwin/alacritty.nix +++ b/modules/darwin/alacritty.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: { # MacOS-specific settings for Alacritty - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { programs.alacritty.settings = { font.size = lib.mkForce 20.0; shell.program = "${pkgs.fish}/bin/fish"; diff --git a/modules/darwin/fonts.nix b/modules/darwin/fonts.nix index 09892c1..1edf526 100644 --- a/modules/darwin/fonts.nix +++ b/modules/darwin/fonts.nix @@ -1,6 +1,6 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home.packages = with pkgs; [ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ]; diff --git a/modules/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix index caf56b4..ebfc5e6 100644 --- a/modules/darwin/hammerspoon.nix +++ b/modules/darwin/hammerspoon.nix @@ -1,28 +1,32 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { # Hammerspoon - MacOS custom automation scripting - home-manager.users.${config.user} = { - xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua; - xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source = - ./hammerspoon/Spoons/ControlEscape.spoon; - xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = - ./hammerspoon/Spoons/DismissAlerts.spoon; - xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = - pkgs.substituteAll { - src = ./hammerspoon/Spoons/Launcher.spoon/init.lua; - firefox = "${pkgs.firefox-bin}/Applications/Firefox.app"; - discord = "${pkgs.discord}/Applications/Discord.app"; - kitty = "${pkgs.kitty}/Applications/kitty.app"; - }; - xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = - ./hammerspoon/Spoons/MoveWindow.spoon; + config = lib.mkIf pkgs.stdenv.isDarwin { + + home-manager.users.${config.user} = { + xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua; + xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source = + ./hammerspoon/Spoons/ControlEscape.spoon; + xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = + ./hammerspoon/Spoons/DismissAlerts.spoon; + xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = + pkgs.substituteAll { + src = ./hammerspoon/Spoons/Launcher.spoon/init.lua; + firefox = "${pkgs.firefox-bin}/Applications/Firefox.app"; + discord = "${pkgs.discord}/Applications/Discord.app"; + kitty = "${pkgs.kitty}/Applications/kitty.app"; + }; + xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = + ./hammerspoon/Spoons/MoveWindow.spoon; + }; + + homebrew.casks = [ "hammerspoon" ]; + + system.activationScripts.postUserActivation.text = '' + defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" + ''; + }; - homebrew.casks = [ "hammerspoon" ]; - - system.activationScripts.postUserActivation.text = '' - defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua" - ''; - } diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 317cd27..40731ab 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -1,52 +1,55 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { # Homebrew - Mac-specific packages that aren't in Nix + config = lib.mkIf pkgs.stdenv.isDarwin { - # Requires Homebrew to be installed - system.activationScripts.preUserActivation.text = '' - if ! xcode-select --version 2>/dev/null; then - $DRY_RUN_CMD xcode-select --install - fi - if ! /usr/local/bin/brew --version 2>/dev/null; then - $DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - fi - ''; + # Requires Homebrew to be installed + system.activationScripts.preUserActivation.text = '' + if ! xcode-select --version 2>/dev/null; then + $DRY_RUN_CMD xcode-select --install + fi + if ! /usr/local/bin/brew --version 2>/dev/null; then + $DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi + ''; - homebrew = { - enable = true; - onActivation = { - autoUpdate = false; # Don't update during rebuild - cleanup = "zap"; # Uninstall all programs not declared - upgrade = true; + homebrew = { + enable = true; + onActivation = { + autoUpdate = false; # Don't update during rebuild + cleanup = "zap"; # Uninstall all programs not declared + upgrade = true; + }; + global = { + brewfile = true; # Run brew bundle from anywhere + lockfiles = false; # Don't save lockfile (since running from anywhere) + }; + taps = [ + "homebrew/cask" # Required for casks + "homebrew/cask-drivers" # Used for Logitech G-Hub + ]; + brews = [ + "trash" # Delete files and folders to trash instead of rm + "openjdk" # Required by Apache Directory Studio + ]; + casks = [ + "1password" # 1Password packaging on Nix is broken for macOS + "scroll-reverser" # Different scroll style for mouse vs. trackpad + "meetingbar" # Show meetings in menu bar + "gitify" # Git notifications in menu bar + "logitech-g-hub" # Mouse and keyboard management + "mimestream" # Gmail client + "obsidian" # Obsidian packaging on Nix is not available for macOS + "steam" # Not packaged for Nix + "apache-directory-studio" # Packaging on Nix is not available for macOS + ]; }; - global = { - brewfile = true; # Run brew bundle from anywhere - lockfiles = false; # Don't save lockfile (since running from anywhere) + + home-manager.users.${config.user} = { + + programs.fish.shellAbbrs.t = "trash"; + }; - taps = [ - "homebrew/cask" # Required for casks - "homebrew/cask-drivers" # Used for Logitech G-Hub - ]; - brews = [ - "trash" # Delete files and folders to trash instead of rm - "openjdk" # Required by Apache Directory Studio - ]; - casks = [ - "1password" # 1Password packaging on Nix is broken for macOS - "scroll-reverser" # Different scroll style for mouse vs. trackpad - "meetingbar" # Show meetings in menu bar - "gitify" # Git notifications in menu bar - "logitech-g-hub" # Mouse and keyboard management - "mimestream" # Gmail client - "obsidian" # Obsidian packaging on Nix is not available for macOS - "steam" # Not packaged for Nix - "apache-directory-studio" # Packaging on Nix is not available for macOS - ]; - }; - - home-manager.users.${config.user} = { - - programs.fish.shellAbbrs.t = "trash"; }; diff --git a/modules/darwin/kitty.nix b/modules/darwin/kitty.nix index 7fb840a..7cd61e2 100644 --- a/modules/darwin/kitty.nix +++ b/modules/darwin/kitty.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: { # MacOS-specific settings for Kitty - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { programs.kitty = { darwinLaunchOptions = [ "--start-as=fullscreen" ]; font.size = lib.mkForce 20; diff --git a/modules/darwin/networking.nix b/modules/darwin/networking.nix index 9d72aff..9d191e1 100644 --- a/modules/darwin/networking.nix +++ b/modules/darwin/networking.nix @@ -1,9 +1,11 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { - networking = { - computerName = "${config.fullName}'\\''s Mac"; - # Adjust if necessary - # hostName = ""; + config = lib.mkIf pkgs.stdenv.isDarwin { + networking = { + computerName = "${config.fullName}'\\''s Mac"; + # Adjust if necessary + # hostName = ""; + }; }; } diff --git a/modules/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix index 7330c27..d1b4778 100644 --- a/modules/darwin/nixpkgs.nix +++ b/modules/darwin/nixpkgs.nix @@ -1,6 +1,6 @@ { config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { programs.fish = { shellAbbrs = { diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index a9083c6..2212c04 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -1,182 +1,186 @@ -{ pkgs, ... }: { +{ pkgs, lib, ... }: { - services.nix-daemon.enable = true; + config = lib.mkIf pkgs.stdenv.isDarwin { - environment.shells = [ pkgs.fish ]; + services.nix-daemon.enable = true; - security.pam.enableSudoTouchIdAuth = true; + environment.shells = [ pkgs.fish ]; - system = { + security.pam.enableSudoTouchIdAuth = true; - keyboard = { - remapCapsLockToControl = true; - enableKeyMapping = true; # Allows for skhd - }; + system = { - defaults = { - NSGlobalDomain = { - - # Set to dark mode - AppleInterfaceStyle = "Dark"; - - # Don't change from dark to light automatically - # AppleInterfaceSwitchesAutomatically = false; - - # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) - AppleKeyboardUIMode = 3; - - # Automatically show and hide the menu bar - _HIHideMenuBar = true; - - # Expand save panel by default - NSNavPanelExpandedStateForSaveMode = true; - - # Expand print panel by default - PMPrintingExpandedStateForPrint = true; - - # Replace press-and-hold with key repeat - ApplePressAndHoldEnabled = false; - - # Set a fast key repeat rate - KeyRepeat = 2; - - # Shorten delay before key repeat begins - InitialKeyRepeat = 12; - - # Save to local disk by default, not iCloud - NSDocumentSaveNewDocumentsToCloud = false; - - # Disable autocorrect capitalization - NSAutomaticCapitalizationEnabled = false; - - # Disable autocorrect smart dashes - NSAutomaticDashSubstitutionEnabled = false; - - # Disable autocorrect adding periods - NSAutomaticPeriodSubstitutionEnabled = false; - - # Disable autocorrect smart quotation marks - NSAutomaticQuoteSubstitutionEnabled = false; - - # Disable autocorrect spellcheck - NSAutomaticSpellingCorrectionEnabled = false; + keyboard = { + remapCapsLockToControl = true; + enableKeyMapping = true; # Allows for skhd }; - dock = { - # Automatically show and hide the dock - autohide = true; + defaults = { + NSGlobalDomain = { - # Add translucency in dock for hidden applications - showhidden = true; + # Set to dark mode + AppleInterfaceStyle = "Dark"; - # Enable spring loading on all dock items - enable-spring-load-actions-on-all-items = true; + # Don't change from dark to light automatically + # AppleInterfaceSwitchesAutomatically = false; - # Highlight hover effect in dock stack grid view - mouse-over-hilite-stack = true; + # Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) + AppleKeyboardUIMode = 3; - mineffect = "genie"; - orientation = "bottom"; - show-recents = false; - tilesize = 44; - }; + # Automatically show and hide the menu bar + _HIHideMenuBar = true; - finder = { + # Expand save panel by default + NSNavPanelExpandedStateForSaveMode = true; - # Default Finder window set to column view - FXPreferredViewStyle = "clmv"; + # Expand print panel by default + PMPrintingExpandedStateForPrint = true; - # Finder search in current folder by default - FXDefaultSearchScope = "SCcf"; + # Replace press-and-hold with key repeat + ApplePressAndHoldEnabled = false; - # Disable warning when changing file extension - FXEnableExtensionChangeWarning = false; + # Set a fast key repeat rate + KeyRepeat = 2; - # Allow quitting of Finder application - QuitMenuItem = true; + # Shorten delay before key repeat begins + InitialKeyRepeat = 12; + + # Save to local disk by default, not iCloud + NSDocumentSaveNewDocumentsToCloud = false; + + # Disable autocorrect capitalization + NSAutomaticCapitalizationEnabled = false; + + # Disable autocorrect smart dashes + NSAutomaticDashSubstitutionEnabled = false; + + # Disable autocorrect adding periods + NSAutomaticPeriodSubstitutionEnabled = false; + + # Disable autocorrect smart quotation marks + NSAutomaticQuoteSubstitutionEnabled = false; + + # Disable autocorrect spellcheck + NSAutomaticSpellingCorrectionEnabled = false; + }; + + dock = { + # Automatically show and hide the dock + autohide = true; + + # Add translucency in dock for hidden applications + showhidden = true; + + # Enable spring loading on all dock items + enable-spring-load-actions-on-all-items = true; + + # Highlight hover effect in dock stack grid view + mouse-over-hilite-stack = true; + + mineffect = "genie"; + orientation = "bottom"; + show-recents = false; + tilesize = 44; + }; + + finder = { + + # Default Finder window set to column view + FXPreferredViewStyle = "clmv"; + + # Finder search in current folder by default + FXDefaultSearchScope = "SCcf"; + + # Disable warning when changing file extension + FXEnableExtensionChangeWarning = false; + + # Allow quitting of Finder application + QuitMenuItem = true; + + }; + + # Disable "Are you sure you want to open" dialog + LaunchServices.LSQuarantine = false; + + # Disable trackpad tap to click + trackpad.Clicking = false; + + # universalaccess = { + + # # Zoom in with Control + Scroll Wheel + # closeViewScrollWheelToggle = true; + # closeViewZoomFollowsFocus = true; + # }; + + # Where to save screenshots + screencapture.location = "~/Downloads"; }; - # Disable "Are you sure you want to open" dialog - LaunchServices.LSQuarantine = false; + # Settings that don't have an option in nix-darwin + activationScripts.postActivation.text = '' + echo "Disable disk image verification" + defaults write com.apple.frameworks.diskimages skip-verify -bool true + defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true + defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true - # Disable trackpad tap to click - trackpad.Clicking = false; + echo "Avoid creating .DS_Store files on network volumes" + defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - # universalaccess = { + echo "Disable the warning before emptying the Trash" + defaults write com.apple.finder WarnOnEmptyTrash -bool false - # # Zoom in with Control + Scroll Wheel - # closeViewScrollWheelToggle = true; - # closeViewZoomFollowsFocus = true; - # }; + echo "Require password immediately after sleep or screen saver begins" + defaults write com.apple.screensaver askForPassword -int 1 + defaults write com.apple.screensaver askForPasswordDelay -int 0 - # Where to save screenshots - screencapture.location = "~/Downloads"; + echo "Allow apps from anywhere" + SPCTL=$(spctl --status) + if ! [ "$SPCTL" = "assessments disabled" ]; then + sudo spctl --master-disable + fi + + ''; + + # User-level settings + activationScripts.postUserActivation.text = '' + echo "Show the ~/Library folder" + chflags nohidden ~/Library + + echo "Enable dock magnification" + defaults write com.apple.dock magnification -bool true + + echo "Set dock magnification size" + defaults write com.apple.dock largesize -int 48 + + echo "Define dock icon function" + __dock_item() { + printf "%s%s%s%s%s" \ + "tile-datafile-data" \ + "_CFURLString" \ + "$1" \ + "_CFURLStringType0" \ + "" + } + + echo "Choose and order dock icons" + defaults write com.apple.dock persistent-apps -array \ + "$(__dock_item /Applications/1Password.app)" \ + "$(__dock_item /Applications/Slack.app)" \ + "$(__dock_item /System/Applications/Calendar.app)" \ + "$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \ + "$(__dock_item /System/Applications/Messages.app)" \ + "$(__dock_item /System/Applications/Mail.app)" \ + "$(__dock_item /Applications/Mimestream.app)" \ + "$(__dock_item /Applications/zoom.us.app)" \ + "$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \ + "$(__dock_item /Applications/Obsidian.app)" \ + "$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \ + "$(__dock_item /System/Applications/System\ Settings.app)" + ''; }; - # Settings that don't have an option in nix-darwin - activationScripts.postActivation.text = '' - echo "Disable disk image verification" - defaults write com.apple.frameworks.diskimages skip-verify -bool true - defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true - defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true - - echo "Avoid creating .DS_Store files on network volumes" - defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - - echo "Disable the warning before emptying the Trash" - defaults write com.apple.finder WarnOnEmptyTrash -bool false - - echo "Require password immediately after sleep or screen saver begins" - defaults write com.apple.screensaver askForPassword -int 1 - defaults write com.apple.screensaver askForPasswordDelay -int 0 - - echo "Allow apps from anywhere" - SPCTL=$(spctl --status) - if ! [ "$SPCTL" = "assessments disabled" ]; then - sudo spctl --master-disable - fi - - ''; - - # User-level settings - activationScripts.postUserActivation.text = '' - echo "Show the ~/Library folder" - chflags nohidden ~/Library - - echo "Enable dock magnification" - defaults write com.apple.dock magnification -bool true - - echo "Set dock magnification size" - defaults write com.apple.dock largesize -int 48 - - echo "Define dock icon function" - __dock_item() { - printf "%s%s%s%s%s" \ - "tile-datafile-data" \ - "_CFURLString" \ - "$1" \ - "_CFURLStringType0" \ - "" - } - - echo "Choose and order dock icons" - defaults write com.apple.dock persistent-apps -array \ - "$(__dock_item /Applications/1Password.app)" \ - "$(__dock_item /Applications/Slack.app)" \ - "$(__dock_item /System/Applications/Calendar.app)" \ - "$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \ - "$(__dock_item /System/Applications/Messages.app)" \ - "$(__dock_item /System/Applications/Mail.app)" \ - "$(__dock_item /Applications/Mimestream.app)" \ - "$(__dock_item /Applications/zoom.us.app)" \ - "$(__dock_item ${pkgs.discord}/Applications/Discord.app)" \ - "$(__dock_item /Applications/Obsidian.app)" \ - "$(__dock_item ${pkgs.kitty}/Applications/kitty.app)" \ - "$(__dock_item /System/Applications/System\ Settings.app)" - ''; - }; } diff --git a/modules/darwin/tmux.nix b/modules/darwin/tmux.nix index 16372e2..95b585a 100644 --- a/modules/darwin/tmux.nix +++ b/modules/darwin/tmux.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer"; + + home-manager.users.${config.user} = lib.mkIf config.tmux.enable { programs.tmux = { enable = true; diff --git a/modules/darwin/user.nix b/modules/darwin/user.nix index a5dc1cb..4ffb691 100644 --- a/modules/darwin/user.nix +++ b/modules/darwin/user.nix @@ -1,15 +1,21 @@ { config, pkgs, lib, ... }: { - users.users."${config.user}" = { - # macOS user - home = config.homePath; - shell = pkgs.fish; # Default shell + config = lib.mkIf pkgs.stdenv.isDarwin { - }; + users.users."${config.user}" = { + # macOS user + home = config.homePath; + shell = pkgs.fish; # Default shell + + }; + + # Used for aerc + home-manager.users.${config.user} = { + home.sessionVariables = { + XDG_CONFIG_HOME = "${config.homePath}/.config"; + }; + }; - # Used for aerc - home-manager.users.${config.user} = { - home.sessionVariables = { XDG_CONFIG_HOME = "${config.homePath}/.config"; }; }; } diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index 07d0a80..90dd067 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -15,7 +15,7 @@ let in { - home-manager.users.${config.user} = { + home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { home.packages = with pkgs; [ # visidata # CSV inspector diff --git a/hosts/common.nix b/modules/default.nix similarity index 92% rename from hosts/common.nix rename to modules/default.nix index 16eb8e2..e5526b7 100644 --- a/hosts/common.nix +++ b/modules/default.nix @@ -1,7 +1,20 @@ { config, lib, pkgs, ... }: { - imports = - [ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ]; + imports = [ + ./applications + ./darwin + ./gaming + ./graphical + ./hardware + ./mail + ./neovim + ./nixos + ./programming + ./repositories + ./services + ./shell + ./wsl + ]; options = { user = lib.mkOption { @@ -36,7 +49,7 @@ colors = lib.mkOption { type = lib.types.attrs; description = "Base16 color scheme."; - default = (import ../modules/colorscheme/gruvbox).dark; + default = (import ../colorscheme/gruvbox).dark; }; dark = lib.mkOption { type = lib.types.bool; diff --git a/modules/gaming/default.nix b/modules/gaming/default.nix index e074730..1b459de 100644 --- a/modules/gaming/default.nix +++ b/modules/gaming/default.nix @@ -1,6 +1,16 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { - config = { + imports = [ + ./leagueoflegends.nix + ./legendary.nix + ./lutris.nix + ./minecraft-server.nix + ./steam.nix + ]; + + options.gaming.enable = lib.mkEnableOption "Enable gaming features."; + + config = lib.mkIf (config.gaming.enable && pkgs.stdenv.isLinux) { hardware.opengl = { enable = true; driSupport32Bit = true; diff --git a/modules/gaming/leagueoflegends.nix b/modules/gaming/leagueoflegends.nix index 3121923..2950d47 100644 --- a/modules/gaming/leagueoflegends.nix +++ b/modules/gaming/leagueoflegends.nix @@ -1,30 +1,32 @@ { config, pkgs, lib, ... }: { - options.gaming.leagueoflegends = lib.mkEnableOption "League of Legends"; + options.gaming.leagueoflegends.enable = + lib.mkEnableOption "League of Legends"; - config = lib.mkIf config.gaming.leagueoflegends { + config = + lib.mkIf (config.gaming.leagueoflegends.enable && pkgs.stdenv.isLinux) { - # League of Legends anti-cheat requirement - boot.kernel.sysctl = { "abi.vsyscall32" = 0; }; + # League of Legends anti-cheat requirement + boot.kernel.sysctl = { "abi.vsyscall32" = 0; }; - environment.systemPackages = with pkgs; [ + environment.systemPackages = with pkgs; [ - # Lutris requirement to install the game - lutris - amdvlk - wineWowPackages.stable - # vulkan-tools + # Lutris requirement to install the game + lutris + amdvlk + wineWowPackages.stable + # vulkan-tools - # Required according to https://lutris.net/games/league-of-legends/ - openssl - gnome.zenity + # Required according to https://lutris.net/games/league-of-legends/ + openssl + gnome.zenity - # Don't remember if this is required - dconf + # Don't remember if this is required + dconf - ]; + ]; - environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; }; + environment.sessionVariables = { QT_X11_NO_MITSHM = "1"; }; - }; + }; } diff --git a/modules/gaming/legendary.nix b/modules/gaming/legendary.nix index f8ce849..018635e 100644 --- a/modules/gaming/legendary.nix +++ b/modules/gaming/legendary.nix @@ -4,9 +4,10 @@ let home-packages = config.home-manager.users.${config.user}.home.packages; in { - imports = [ ./. ]; + options.gaming.legendary.enable = + lib.mkEnableOption "Legendary Epic Games launcher."; - config = { + config = lib.mkIf config.gaming.legendary.enable { environment.systemPackages = with pkgs; [ legendary-gl rare # GUI for Legendary (not working) diff --git a/modules/gaming/lutris.nix b/modules/gaming/lutris.nix index a8cac00..d2783e3 100644 --- a/modules/gaming/lutris.nix +++ b/modules/gaming/lutris.nix @@ -1,8 +1,8 @@ { config, pkgs, lib, ... }: { - options.gaming.lutris = lib.mkEnableOption "Lutris"; + options.gaming.lutris.enable = lib.mkEnableOption "Lutris game installer."; - config = lib.mkIf config.gaming.lutris { + config = lib.mkIf config.gaming.lutris.enable { environment.systemPackages = with pkgs; [ lutris amdvlk # Vulkan drivers (probably already installed) diff --git a/modules/gaming/minecraft-server.nix b/modules/gaming/minecraft-server.nix index 822cdab..34c6562 100644 --- a/modules/gaming/minecraft-server.nix +++ b/modules/gaming/minecraft-server.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, pkgs, lib, ... }: let @@ -9,137 +9,144 @@ let in { - unfreePackages = [ "minecraft-server" ]; + options.gaming.minecraft-server.enable = + lib.mkEnableOption "Minecraft Server."; - services.minecraft-server = { - enable = true; - eula = true; - declarative = true; - whitelist = { }; - openFirewall = false; - serverProperties = { - server-port = localPort; - difficulty = "normal"; - gamemode = "survival"; - white-list = false; - enforce-whitelist = false; - level-name = "world"; - motd = "Welcome!"; - pvp = true; - player-idle-timeout = 30; - generate-structures = true; - max-players = 20; - snooper-enabled = false; - spawn-npcs = true; - spawn-animals = true; - spawn-monsters = true; - allow-nether = true; - allow-flight = false; - enable-rcon = true; - "rcon.port" = rconPort; - "rcon.password" = rconPassword; + config = lib.mkIf config.gaming.minecraft-server.enable { + + unfreePackages = [ "minecraft-server" ]; + + services.minecraft-server = { + enable = true; + eula = true; + declarative = true; + whitelist = { }; + openFirewall = false; + serverProperties = { + server-port = localPort; + difficulty = "normal"; + gamemode = "survival"; + white-list = false; + enforce-whitelist = false; + level-name = "world"; + motd = "Welcome!"; + pvp = true; + player-idle-timeout = 30; + generate-structures = true; + max-players = 20; + snooper-enabled = false; + spawn-npcs = true; + spawn-animals = true; + spawn-monsters = true; + allow-nether = true; + allow-flight = false; + enable-rcon = true; + "rcon.port" = rconPort; + "rcon.password" = rconPassword; + }; }; - }; - networking.firewall.allowedTCPPorts = [ publicPort ]; + networking.firewall.allowedTCPPorts = [ publicPort ]; - ## Automatically start and stop Minecraft server based on player connections + ## Automatically start and stop Minecraft server based on player connections - # Adapted shamelessly from: - # https://dataswamp.org/~solene/2022-08-20-on-demand-minecraft-with-systemd.html + # Adapted shamelessly from: + # https://dataswamp.org/~solene/2022-08-20-on-demand-minecraft-with-systemd.html - # Prevent Minecraft from starting by default - systemd.services.minecraft-server = { wantedBy = pkgs.lib.mkForce [ ]; }; + # Prevent Minecraft from starting by default + systemd.services.minecraft-server = { wantedBy = pkgs.lib.mkForce [ ]; }; - # Listen for connections on the public port, to trigger the actual - # listen-minecraft service. - systemd.sockets.listen-minecraft = { - wantedBy = [ "sockets.target" ]; - requires = [ "network.target" ]; - listenStreams = [ "${toString publicPort}" ]; - }; + # Listen for connections on the public port, to trigger the actual + # listen-minecraft service. + systemd.sockets.listen-minecraft = { + wantedBy = [ "sockets.target" ]; + requires = [ "network.target" ]; + listenStreams = [ "${toString publicPort}" ]; + }; - # Proxy traffic to local port, and trigger hook-minecraft - systemd.services.listen-minecraft = { - path = [ pkgs.systemd ]; - requires = [ "hook-minecraft.service" "listen-minecraft.socket" ]; - after = [ "hook-minecraft.service" "listen-minecraft.socket" ]; - serviceConfig.ExecStart = - "${pkgs.systemd.out}/lib/systemd/systemd-socket-proxyd 127.0.0.1:${ - toString localPort - }"; - }; - - # Start Minecraft if required and wait for it to be available - # Then unlock the listen-minecraft.service - systemd.services.hook-minecraft = { - path = with pkgs; [ systemd libressl busybox ]; - - # Start Minecraft and the auto-shutdown timer - script = '' - systemctl start minecraft-server.service - systemctl start stop-minecraft.timer - ''; - - # Keep checking until the service is available - postStart = '' - for i in $(seq 60); do - if ${pkgs.libressl.nc}/bin/nc -z 127.0.0.1 ${ + # Proxy traffic to local port, and trigger hook-minecraft + systemd.services.listen-minecraft = { + path = [ pkgs.systemd ]; + requires = [ "hook-minecraft.service" "listen-minecraft.socket" ]; + after = [ "hook-minecraft.service" "listen-minecraft.socket" ]; + serviceConfig.ExecStart = + "${pkgs.systemd.out}/lib/systemd/systemd-socket-proxyd 127.0.0.1:${ toString localPort - } > /dev/null ; then + }"; + }; + + # Start Minecraft if required and wait for it to be available + # Then unlock the listen-minecraft.service + systemd.services.hook-minecraft = { + path = with pkgs; [ systemd libressl busybox ]; + + # Start Minecraft and the auto-shutdown timer + script = '' + systemctl start minecraft-server.service + systemctl start stop-minecraft.timer + ''; + + # Keep checking until the service is available + postStart = '' + for i in $(seq 60); do + if ${pkgs.libressl.nc}/bin/nc -z 127.0.0.1 ${ + toString localPort + } > /dev/null ; then + exit 0 + fi + ${pkgs.busybox.out}/bin/sleep 1 + done + exit 1 + ''; + }; + + # Run a player check on a schedule for auto-shutdown + systemd.timers.stop-minecraft = { + timerConfig = { + OnCalendar = "*-*-* *:*:0/20"; # Every 20 seconds + Unit = "stop-minecraft.service"; + }; + }; + + # If no players are connected, then stop services and prepare to resume again + systemd.services.stop-minecraft = { + serviceConfig.Type = "oneshot"; + script = '' + # Check when service was launched + servicestartsec=$( + date -d \ + "$(systemctl show \ + --property=ActiveEnterTimestamp \ + minecraft-server.service \ + | cut -d= -f2)" \ + +%s) + + # Calculate elapsed time + serviceelapsedsec=$(( $(date +%s) - servicestartsec)) + + # Ignore if service just started + if [ $serviceelapsedsec -lt 180 ] + then + echo "Server was just started" exit 0 fi - ${pkgs.busybox.out}/bin/sleep 1 - done - exit 1 - ''; - }; - # Run a player check on a schedule for auto-shutdown - systemd.timers.stop-minecraft = { - timerConfig = { - OnCalendar = "*-*-* *:*:0/20"; # Every 20 seconds - Unit = "stop-minecraft.service"; + PLAYERS=$( + printf "list\n" \ + | ${pkgs.rcon.out}/bin/rcon -m \ + -H 127.0.0.1 -p ${builtins.toString rconPort} -P ${rconPassword} \ + ) + + if echo "$PLAYERS" | grep "are 0 of a" + then + echo "Stopping server" + systemctl stop minecraft-server.service + systemctl stop hook-minecraft.service + systemctl stop stop-minecraft.timer + fi + ''; }; - }; - # If no players are connected, then stop services and prepare to resume again - systemd.services.stop-minecraft = { - serviceConfig.Type = "oneshot"; - script = '' - # Check when service was launched - servicestartsec=$( - date -d \ - "$(systemctl show \ - --property=ActiveEnterTimestamp \ - minecraft-server.service \ - | cut -d= -f2)" \ - +%s) - - # Calculate elapsed time - serviceelapsedsec=$(( $(date +%s) - servicestartsec)) - - # Ignore if service just started - if [ $serviceelapsedsec -lt 180 ] - then - echo "Server was just started" - exit 0 - fi - - PLAYERS=$( - printf "list\n" \ - | ${pkgs.rcon.out}/bin/rcon -m \ - -H 127.0.0.1 -p ${builtins.toString rconPort} -P ${rconPassword} \ - ) - - if echo "$PLAYERS" | grep "are 0 of a" - then - echo "Stopping server" - systemctl stop minecraft-server.service - systemctl stop hook-minecraft.service - systemctl stop stop-minecraft.timer - fi - ''; }; } diff --git a/modules/gaming/steam.nix b/modules/gaming/steam.nix index 61cf5c5..896c27e 100644 --- a/modules/gaming/steam.nix +++ b/modules/gaming/steam.nix @@ -1,8 +1,8 @@ { config, pkgs, lib, ... }: { - imports = [ ./. ]; + options.gaming.steam.enable = lib.mkEnableOption "Steam game launcher."; - config = { + config = lib.mkIf (config.gaming.steam.enable && pkgs.stdenv.isLinux) { hardware.steam-hardware.enable = true; unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ]; environment.systemPackages = with pkgs; [ diff --git a/modules/graphical/dmenu.nix b/modules/graphical/dmenu.nix index 9ada181..962f8ae 100644 --- a/modules/graphical/dmenu.nix +++ b/modules/graphical/dmenu.nix @@ -2,7 +2,9 @@ { - config = lib.mkIf config.services.xserver.enable { + options.gui.dmenu.enable = lib.mkEnableOption "dmenu launcher."; + + config = lib.mkIf (config.services.xserver.enable && config.dmenu.enable) { home-manager.users.${config.user}.home.packages = [ pkgs.dmenu ]; gui.launcherCommand = "${pkgs.dmenu}/bin/dmenu_run"; diff --git a/modules/graphical/fonts.nix b/modules/graphical/fonts.nix index 55d6245..9fb8191 100644 --- a/modules/graphical/fonts.nix +++ b/modules/graphical/fonts.nix @@ -4,7 +4,7 @@ let fontName = "Victor Mono"; in { - config = lib.mkIf config.gui.enable { + config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) { fonts.fonts = with pkgs; [ victor-mono # Used for Vim and Terminal diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index a7d368b..dfaaed4 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -9,7 +9,7 @@ let in { - config = { + config = lib.mkIf pkgs.stdenv.isLinux { services.xserver.windowManager = { i3 = { diff --git a/modules/graphical/picom.nix b/modules/graphical/picom.nix index 47db1fa..819c8f3 100644 --- a/modules/graphical/picom.nix +++ b/modules/graphical/picom.nix @@ -1,6 +1,6 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { - config = lib.mkIf (config.services.xserver.enable) { + config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { home-manager.users.${config.user} = { services.picom = { diff --git a/modules/graphical/polybar.nix b/modules/graphical/polybar.nix index 9098326..d8457a9 100644 --- a/modules/graphical/polybar.nix +++ b/modules/graphical/polybar.nix @@ -1,6 +1,6 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.services.xserver.enable { + config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { toggleBarCommand = "polybar-msg cmd toggle"; diff --git a/modules/graphical/rofi.nix b/modules/graphical/rofi.nix index 5a8674a..7a580c6 100644 --- a/modules/graphical/rofi.nix +++ b/modules/graphical/rofi.nix @@ -2,7 +2,7 @@ { - config = lib.mkIf config.services.xserver.enable { + config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { home-manager.users.${config.user} = { diff --git a/modules/graphical/xorg.nix b/modules/graphical/xorg.nix index 868a299..fab1510 100644 --- a/modules/graphical/xorg.nix +++ b/modules/graphical/xorg.nix @@ -15,11 +15,13 @@ }; config = let + gtkTheme = { name = config.gtk.theme.name; package = pkgs."${config.gtk.theme.package}"; }; - in lib.mkIf config.gui.enable { + + in lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) { # Enable the X11 windowing system. services.xserver = { diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 6d0f234..72e32cd 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -30,7 +30,7 @@ let in { - config = lib.mkIf config.gui.enable { + config = lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) { sound.enable = true; # Enable PipeWire diff --git a/modules/hardware/boot.nix b/modules/hardware/boot.nix index d92941f..3d30be8 100644 --- a/modules/hardware/boot.nix +++ b/modules/hardware/boot.nix @@ -1,6 +1,6 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { - boot.loader = { + boot.loader = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { grub = { enable = true; diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index fd15c7e..781e7f7 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -1,4 +1,4 @@ -{ ... }: { +{ lib, ... }: { imports = [ ./audio.nix @@ -11,4 +11,9 @@ ./wifi.nix ]; + options = { + physical = lib.mkEnableOption "Whether this machine is a physical device."; + server = lib.mkEnableOption "Whether this machine is a server."; + }; + } diff --git a/modules/hardware/monitors.nix b/modules/hardware/monitors.nix index 3ae0e6c..297c475 100644 --- a/modules/hardware/monitors.nix +++ b/modules/hardware/monitors.nix @@ -3,51 +3,52 @@ # Timezone required for Redshift schedule imports = [ ../nixos/timezone.nix ]; - config = lib.mkIf config.gui.enable { + config = + lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) { - environment.systemPackages = with pkgs; - [ - ddcutil # Monitor brightness control - ]; + environment.systemPackages = with pkgs; + [ + ddcutil # Monitor brightness control + ]; - # Reduce blue light at night - services.redshift = { - enable = true; - brightness = { - day = "1.0"; - night = "1.0"; + # Reduce blue light at night + services.redshift = { + enable = true; + brightness = { + day = "1.0"; + night = "1.0"; + }; }; + + # Detect monitors (brightness) for ddcutil + hardware.i2c.enable = true; + + # Grant main user access to external monitors + users.users.${config.user}.extraGroups = [ "i2c" ]; + + services.xserver.displayManager = { + + # Put the login screen on the left monitor + lightdm.greeters.gtk.extraConfig = '' + active-monitor=0 + ''; + + # Set up screen position and rotation + setupCommands = '' + ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ + --mode 1920x1200 \ + --pos 1920x0 \ + --rotate left \ + --output HDMI-0 \ + --primary \ + --mode 1920x1080 \ + --pos 0x560 \ + --rotate normal \ + --output DVI-0 --off \ + --output DVI-1 --off \ + ''; + }; + }; - # Detect monitors (brightness) for ddcutil - hardware.i2c.enable = true; - - # Grant main user access to external monitors - users.users.${config.user}.extraGroups = [ "i2c" ]; - - services.xserver.displayManager = { - - # Put the login screen on the left monitor - lightdm.greeters.gtk.extraConfig = '' - active-monitor=0 - ''; - - # Set up screen position and rotation - setupCommands = '' - ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ - --mode 1920x1200 \ - --pos 1920x0 \ - --rotate left \ - --output HDMI-0 \ - --primary \ - --mode 1920x1080 \ - --pos 0x560 \ - --rotate normal \ - --output DVI-0 --off \ - --output DVI-1 --off \ - ''; - }; - - }; - } diff --git a/modules/hardware/mouse.nix b/modules/hardware/mouse.nix index cb3d7f5..cf75074 100644 --- a/modules/hardware/mouse.nix +++ b/modules/hardware/mouse.nix @@ -1,21 +1,22 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf config.gui.enable { + config = + lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) { - # Mouse customization - services.ratbagd.enable = true; + # Mouse customization + services.ratbagd.enable = true; - environment.systemPackages = with pkgs; [ - libratbag # Mouse adjustments - piper # Mouse adjustments GUI - ]; + environment.systemPackages = with pkgs; [ + libratbag # Mouse adjustments + piper # Mouse adjustments GUI + ]; + + services.xserver.libinput.mouse = { + # Disable mouse acceleration + accelProfile = "flat"; + accelSpeed = "1.15"; + }; - services.xserver.libinput.mouse = { - # Disable mouse acceleration - accelProfile = "flat"; - accelSpeed = "1.15"; }; - }; - } diff --git a/modules/hardware/networking.nix b/modules/hardware/networking.nix index 4fb79a6..a9017bd 100644 --- a/modules/hardware/networking.nix +++ b/modules/hardware/networking.nix @@ -1,10 +1,14 @@ -{ ... }: { +{ config, pkgs, lib, ... }: { - # The global useDHCP flag is deprecated, therefore explicitly set to false here. - # Per-interface useDHCP will be mandatory in the future, so this generated config - # replicates the default behaviour. - networking.useDHCP = false; - networking.interfaces.enp0s31f6.useDHCP = true; - networking.interfaces.wlp3s0.useDHCP = true; + config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.enp0s31f6.useDHCP = true; + networking.interfaces.wlp3s0.useDHCP = true; + + }; } diff --git a/modules/hardware/server.nix b/modules/hardware/server.nix index 7647b8e..67ea035 100644 --- a/modules/hardware/server.nix +++ b/modules/hardware/server.nix @@ -1,7 +1,11 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { - # Servers need a bootloader or they won't start - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; + config = lib.mkIf (pkgs.stdenv.isLinux && config.server) { + + # Servers need a bootloader or they won't start + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + }; } diff --git a/modules/hardware/sleep.nix b/modules/hardware/sleep.nix index 3b7d4bb..1a1aa5f 100644 --- a/modules/hardware/sleep.nix +++ b/modules/hardware/sleep.nix @@ -1,8 +1,12 @@ -{ ... }: { +{ config, pkgs, lib, ... }: { - # Prevent wake from keyboard - powerManagement.powerDownCommands = '' - for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done - ''; + config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { + + # Prevent wake from keyboard + powerManagement.powerDownCommands = '' + for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done + ''; + + }; } diff --git a/modules/hardware/wifi.nix b/modules/hardware/wifi.nix index 290044e..10fd4f9 100644 --- a/modules/hardware/wifi.nix +++ b/modules/hardware/wifi.nix @@ -1,9 +1,13 @@ -{ ... }: { +{ config, pkgs, lib, ... }: { - # Enables wireless support via wpa_supplicant. - networking.wireless.enable = true; + config = lib.mkIf (config.physical && config.isLinux) { - # Allows the user to control the WiFi settings. - networking.wireless.userControlled.enable = true; + # Enables wireless support via wpa_supplicant. + networking.wireless.enable = true; + + # Allows the user to control the WiFi settings. + networking.wireless.userControlled.enable = true; + + }; } diff --git a/modules/mail/aerc.nix b/modules/mail/aerc.nix index 39ca79a..c85d62b 100644 --- a/modules/mail/aerc.nix +++ b/modules/mail/aerc.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - config = { + options.mail.aerc.enable = lib.mkEnableOption "Aerc email."; + + config = lib.mkIf config.mail.aerc.enable { home-manager.users.${config.user} = { diff --git a/modules/mail/default.nix b/modules/mail/default.nix index 61a7117..24ac7e1 100644 --- a/modules/mail/default.nix +++ b/modules/mail/default.nix @@ -3,18 +3,18 @@ imports = [ ./himalaya.nix ./aerc.nix ]; options = { - mailUser = lib.mkOption { + mail.user = lib.mkOption { type = lib.types.str; description = "User name for the email address."; default = config.user; }; - mailServer = lib.mkOption { + mail.server = lib.mkOption { type = lib.types.str; description = "Server name for the email address."; }; }; - config = { + config = lib.mkIf (config.mail.user != null && config.mail.server != null) { home-manager.users.${config.user} = { programs.mbsync = { enable = true; }; @@ -25,13 +25,13 @@ accounts.email = { maildirBasePath = "${config.homePath}/mail"; accounts = { - home = let address = "${config.mailUser}@${config.mailServer}"; + home = let address = "${config.mail.user}@${config.mail.server}"; in { userName = address; realName = config.fullName; primary = true; inherit address; - aliases = map (mailUser: "${mailUser}@${config.mailServer}") [ + aliases = map (user: "${user}@${config.mail.server}") [ "me" "hey" "admin" diff --git a/modules/mail/himalaya.nix b/modules/mail/himalaya.nix index 4363dd5..bf627b1 100644 --- a/modules/mail/himalaya.nix +++ b/modules/mail/himalaya.nix @@ -1,6 +1,8 @@ -{ config, ... }: { +{ config, lib, ... }: { - config = { + options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email."; + + config = lib.mkIf config.mail.himalaya.enable { home-manager.users.${config.user} = { diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index c435342..cf23eb3 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -9,31 +9,36 @@ let in { - home-manager.users.${config.user} = + options.neovim.enable = lib.mkEnableOption "Neovim."; - { + config = lib.mkIf config.neovim.enable { + home-manager.users.${config.user} = - home.packages = [ neovim ]; + { - programs.git.extraConfig.core.editor = "nvim"; - home.sessionVariables = { - EDITOR = "nvim"; - MANPAGER = "nvim +Man!"; - }; - programs.fish = { - shellAliases = { vim = "nvim"; }; - shellAbbrs = { - v = lib.mkForce "nvim"; - vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'"; - vll = "nvim -c 'Telescope oldfiles'"; + home.packages = [ neovim ]; + + programs.git.extraConfig.core.editor = "nvim"; + home.sessionVariables = { + EDITOR = "nvim"; + MANPAGER = "nvim +Man!"; }; + programs.fish = { + shellAliases = { vim = "nvim"; }; + shellAbbrs = { + v = lib.mkForce "nvim"; + vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'"; + vll = "nvim -c 'Telescope oldfiles'"; + }; + }; + programs.kitty.settings.scrollback_pager = lib.mkForce '' + ${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; + }; - programs.kitty.settings.scrollback_pager = lib.mkForce '' - ${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; - }; + # # Used for icons in Vim + # fonts.fonts = with pkgs; [ nerdfonts ]; - # # Used for icons in Vim - # fonts.fonts = with pkgs; [ nerdfonts ]; + }; } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index b5cc4b8..d23505b 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,9 +1,13 @@ -{ config, ... }: { +{ config, pkgs, lib, ... }: { imports = [ ./user.nix ./timezone.nix ./doas.nix ]; - # Pin a state version to prevent warnings - system.stateVersion = - config.home-manager.users.${config.user}.home.stateVersion; + config = lib.mkIf pkgs.stdenv.isLinux { + + # Pin a state version to prevent warnings + system.stateVersion = + config.home-manager.users.${config.user}.home.stateVersion; + + }; } diff --git a/modules/nixos/doas.nix b/modules/nixos/doas.nix index bbe48b8..f2cff94 100644 --- a/modules/nixos/doas.nix +++ b/modules/nixos/doas.nix @@ -1,30 +1,35 @@ # Replace sudo with doas -{ config, ... }: { +{ config, pkgs, lib, ... }: { - security = { + config = lib.mkIf pkgs.stdenv.isLinux { - # Remove sudo - sudo.enable = false; + security = { - # Add doas - doas = { - enable = true; + # Remove sudo + sudo.enable = false; - # No password required - wheelNeedsPassword = false; + # Add doas + doas = { + enable = true; - # Pass environment variables from user to root - # Also requires removing password here - extraRules = [{ - groups = [ "wheel" ]; - noPass = true; - keepEnv = true; - }]; + # No password required + wheelNeedsPassword = false; + + # Pass environment variables from user to root + # Also requires removing password here + extraRules = [{ + groups = [ "wheel" ]; + noPass = true; + keepEnv = true; + }]; + }; }; + + home-manager.users.${config.user}.programs.fish.shellAliases = { + sudo = "doas"; + }; + }; - home-manager.users.${config.user}.programs.fish.shellAliases = { - sudo = "doas"; - }; } diff --git a/modules/nixos/timezone.nix b/modules/nixos/timezone.nix index 896af0b..a47ed03 100644 --- a/modules/nixos/timezone.nix +++ b/modules/nixos/timezone.nix @@ -1,15 +1,19 @@ -{ ... }: { +{ config, pkgs, lib, ... }: { - # Service to determine location for time zone - services.geoclue2.enable = true; - services.geoclue2.enableWifi = false; # Breaks when it can't connect - location = { provider = "geoclue2"; }; + config = lib.mkIf pkgs.stdenv.isLinux { - # Enable local time based on time zone - services.localtimed.enable = true; + # Service to determine location for time zone + services.geoclue2.enable = true; + services.geoclue2.enableWifi = false; # Breaks when it can't connect + location = { provider = "geoclue2"; }; - # Required to get localtimed to talk to geoclue2 - services.geoclue2.appConfig.localtimed.isSystem = true; - services.geoclue2.appConfig.localtimed.isAllowed = true; + # Enable local time based on time zone + services.localtimed.enable = true; + + # Required to get localtimed to talk to geoclue2 + services.geoclue2.appConfig.localtimed.isSystem = true; + services.geoclue2.appConfig.localtimed.isAllowed = true; + + }; } diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix index 54a17a8..5895624 100644 --- a/modules/nixos/user.nix +++ b/modules/nixos/user.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { options = { @@ -11,7 +11,7 @@ }; - config = { + config = lib.mkIf (pkgs.stdenv.isLinux) { # Allows us to declaritively set password users.mutableUsers = false; diff --git a/modules/programming/default.nix b/modules/programming/default.nix new file mode 100644 index 0000000..9650fc7 --- /dev/null +++ b/modules/programming/default.nix @@ -0,0 +1,12 @@ +{ config, pkgs, lib, ... }: { + + imports = [ + ./haskell.nix + ./kubernetes.nix + ./lua.nix + ./nix.nix + ./python.nix + ./terraform.nix + ]; + +} diff --git a/modules/programming/haskell.nix b/modules/programming/haskell.nix index 0439350..7bf3df7 100644 --- a/modules/programming/haskell.nix +++ b/modules/programming/haskell.nix @@ -1,8 +1,14 @@ -{ ... }: { +{ config, pkgs, lib, ... }: { - # Binary Cache for Haskell.nix - nix.settings.trusted-public-keys = - [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; - nix.settings.substituters = [ "https://cache.iog.io" ]; + options.haskell.enable = lib.mkEnableOption "Haskell programming language."; + + config = lib.mkIf config.haskell.enable { + + # Binary Cache for Haskell.nix + nix.settings.trusted-public-keys = + [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; + nix.settings.substituters = [ "https://cache.iog.io" ]; + + }; } diff --git a/modules/programming/kubernetes.nix b/modules/programming/kubernetes.nix index 3f4a849..8864b8b 100644 --- a/modules/programming/kubernetes.nix +++ b/modules/programming/kubernetes.nix @@ -1,138 +1,143 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.kubernetes.enable = lib.mkEnableOption "Kubernetes tools."; - home.packages = with pkgs; [ - kubectl # Basic Kubernetes queries - kubernetes-helm # Helm CLI - fluxcd # Bootstrap clusters with Flux - kustomize # Kustomize CLI (for Flux) - ]; + config = lib.mkIf config.kubernetes.enable { + home-manager.users.${config.user} = { - programs.fish.shellAbbrs = { - k = "kubectl"; - pods = "kubectl get pods -A"; - nodes = "kubectl get nodes"; - deploys = "kubectl get deployments -A"; - dash = "kube-dashboard"; - ks = "k9s"; - }; + home.packages = with pkgs; [ + kubectl # Basic Kubernetes queries + kubernetes-helm # Helm CLI + fluxcd # Bootstrap clusters with Flux + kustomize # Kustomize CLI (for Flux) + ]; - # Terminal Kubernetes UI - programs.k9s = { - enable = true; - # settings = { k9s = { headless = true; }; }; - skin = { - k9s = { - body = { - fgColor = config.theme.colors.base06; - bgColor = config.theme.colors.base00; - logoColor = config.theme.colors.base02; # *blue ? - }; - # Search bar - prompt = { - fgColor = config.theme.colors.base06; - bgColor = config.theme.colors.base00; - suggestColor = config.theme.colors.base03; - }; - # Header left side - info = { - fgColor = config.theme.colors.base04; - sectionColor = config.theme.colors.base05; - }; - dialog = { - fgColor = config.theme.colors.base06; - bgColor = config.theme.colors.base00; - buttonFgColor = config.theme.colors.base06; - buttonBgColor = config.theme.colors.base0E; - buttonFocusFgColor = config.theme.colors.base07; - buttonFocusBgColor = config.theme.colors.base02; # *cyan - labelFgColor = config.theme.colors.base09; - fieldFgColor = config.theme.colors.base06; - }; - frame = { - border = { - fgColor = config.theme.colors.base01; - focusColor = config.theme.colors.base06; - }; - menu = { - fgColor = config.theme.colors.base06; - keyColor = config.theme.colors.base0E; # *magenta - numKeyColor = config.theme.colors.base0E; # *magenta - }; - crumbs = { - fgColor = config.theme.colors.base06; - bgColor = config.theme.colors.base01; - activeColor = config.theme.colors.base03; - }; - status = { - newColor = config.theme.colors.base04; # *cyan - modifyColor = config.theme.colors.base0D; # *blue - addColor = config.theme.colors.base0B; # *green - errorColor = config.theme.colors.base08; # *red - highlightColor = config.theme.colors.base09; # *orange - killColor = config.theme.colors.base03; # *comment - completedColor = config.theme.colors.base03; # *comment - }; - title = { + programs.fish.shellAbbrs = { + k = "kubectl"; + pods = "kubectl get pods -A"; + nodes = "kubectl get nodes"; + deploys = "kubectl get deployments -A"; + dash = "kube-dashboard"; + ks = "k9s"; + }; + + # Terminal Kubernetes UI + programs.k9s = { + enable = true; + # settings = { k9s = { headless = true; }; }; + skin = { + k9s = { + body = { fgColor = config.theme.colors.base06; bgColor = config.theme.colors.base00; - highlightColor = config.theme.colors.base09; # *orange - counterColor = config.theme.colors.base0D; # *blue - filterColor = config.theme.colors.base0E; # *magenta + logoColor = config.theme.colors.base02; # *blue ? }; - }; - views = { - charts = { - bgColor = config.theme.colors.base00; - defaultDialColors = - [ config.theme.colors.base0D config.theme.colors.base08 ]; - # - *blue - # - *red - defaultChartColors = - [ config.theme.colors.base0D config.theme.colors.base08 ]; - # - *blue - # - *red - }; - table = { - # List of resources + # Search bar + prompt = { fgColor = config.theme.colors.base06; bgColor = config.theme.colors.base00; - - # Row selection - cursorFgColor = config.theme.colors.base07; - cursorBgColor = config.theme.colors.base01; - - # Header row - header = { - fgColor = config.theme.colors.base0D; - bgColor = config.theme.colors.base00; - sorterColor = config.theme.colors.base0A; # *selection + suggestColor = config.theme.colors.base03; + }; + # Header left side + info = { + fgColor = config.theme.colors.base04; + sectionColor = config.theme.colors.base05; + }; + dialog = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + buttonFgColor = config.theme.colors.base06; + buttonBgColor = config.theme.colors.base0E; + buttonFocusFgColor = config.theme.colors.base07; + buttonFocusBgColor = config.theme.colors.base02; # *cyan + labelFgColor = config.theme.colors.base09; + fieldFgColor = config.theme.colors.base06; + }; + frame = { + border = { + fgColor = config.theme.colors.base01; + focusColor = config.theme.colors.base06; }; - }; - xray = { - fgColor = config.theme.colors.base06; - bgColor = config.theme.colors.base00; - cursorColor = config.theme.colors.base06; - graphicColor = config.theme.colors.base0D; - showIcons = false; - }; - yaml = { - keyColor = config.theme.colors.base0D; - colonColor = config.theme.colors.base04; - fgColor = config.theme.colors.base03; - }; - logs = { - fgColor = config.theme.colors.base06; - bgColor = config.theme.colors.base00; - indicator = { + menu = { + fgColor = config.theme.colors.base06; + keyColor = config.theme.colors.base0E; # *magenta + numKeyColor = config.theme.colors.base0E; # *magenta + }; + crumbs = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base01; + activeColor = config.theme.colors.base03; + }; + status = { + newColor = config.theme.colors.base04; # *cyan + modifyColor = config.theme.colors.base0D; # *blue + addColor = config.theme.colors.base0B; # *green + errorColor = config.theme.colors.base08; # *red + highlightColor = config.theme.colors.base09; # *orange + killColor = config.theme.colors.base03; # *comment + completedColor = config.theme.colors.base03; # *comment + }; + title = { fgColor = config.theme.colors.base06; bgColor = config.theme.colors.base00; + highlightColor = config.theme.colors.base09; # *orange + counterColor = config.theme.colors.base0D; # *blue + filterColor = config.theme.colors.base0E; # *magenta + }; + }; + views = { + charts = { + bgColor = config.theme.colors.base00; + defaultDialColors = + [ config.theme.colors.base0D config.theme.colors.base08 ]; + # - *blue + # - *red + defaultChartColors = + [ config.theme.colors.base0D config.theme.colors.base08 ]; + # - *blue + # - *red + }; + table = { + # List of resources + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + + # Row selection + cursorFgColor = config.theme.colors.base07; + cursorBgColor = config.theme.colors.base01; + + # Header row + header = { + fgColor = config.theme.colors.base0D; + bgColor = config.theme.colors.base00; + sorterColor = config.theme.colors.base0A; # *selection + }; + }; + xray = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + cursorColor = config.theme.colors.base06; + graphicColor = config.theme.colors.base0D; + showIcons = false; + }; + yaml = { + keyColor = config.theme.colors.base0D; + colonColor = config.theme.colors.base04; + fgColor = config.theme.colors.base03; + }; + logs = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + indicator = { + fgColor = config.theme.colors.base06; + bgColor = config.theme.colors.base00; + }; }; }; }; }; }; + }; }; diff --git a/modules/programming/lua.nix b/modules/programming/lua.nix index e4de60f..127623d 100644 --- a/modules/programming/lua.nix +++ b/modules/programming/lua.nix @@ -1,8 +1,12 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user}.home.packages = with pkgs; [ - stylua # Lua formatter - sumneko-lua-language-server # Lua LSP - ]; + options.lua.enable = lib.mkEnableOption "Lua programming language."; + + config = lib.mkIf config.lua.enable { + home-manager.users.${config.user}.home.packages = with pkgs; [ + stylua # Lua formatter + sumneko-lua-language-server # Lua LSP + ]; + }; } diff --git a/modules/programming/nix.nix b/modules/programming/nix.nix index 272b227..20a297d 100644 --- a/modules/programming/nix.nix +++ b/modules/programming/nix.nix @@ -1,11 +1,17 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.nixlang.enable = lib.mkEnableOption "Nix programming language."; - home.packages = with pkgs; [ - nixfmt # Nix file formatter - nil # Nix language server - ]; + config = lib.mkIf config.nixlang.enable { + + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + nixfmt # Nix file formatter + nil # Nix language server + ]; + + }; }; diff --git a/modules/programming/python.nix b/modules/programming/python.nix index d2bde89..e3d435f 100644 --- a/modules/programming/python.nix +++ b/modules/programming/python.nix @@ -1,15 +1,21 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.python.enable = lib.mkEnableOption "Python programming language."; - home.packages = with pkgs; [ - # python310 # Standard Python interpreter - nodePackages.pyright # Python language server - black # Python formatter - python310Packages.flake8 # Python linter - ]; + config = lib.mkIf config.python.enable { - programs.fish.shellAbbrs = { py = "python3"; }; + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + # python310 # Standard Python interpreter + nodePackages.pyright # Python language server + black # Python formatter + python310Packages.flake8 # Python linter + ]; + + programs.fish.shellAbbrs = { py = "python3"; }; + + }; }; diff --git a/modules/programming/terraform.nix b/modules/programming/terraform.nix index 28db982..9a5f3e1 100644 --- a/modules/programming/terraform.nix +++ b/modules/programming/terraform.nix @@ -1,15 +1,21 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { + + options.terraform.enable = lib.mkEnableOption "Terraform tools."; + + config = lib.mkIf config.terraform.enable { + + home-manager.users.${config.user} = { + programs.fish.shellAbbrs = { + # Terraform + te = "terraform"; + }; + home.packages = with pkgs; [ + terraform # Terraform executable + terraform-ls # Language server + tflint # Linter + ]; - home-manager.users.${config.user} = { - programs.fish.shellAbbrs = { - # Terraform - te = "terraform"; }; - home.packages = with pkgs; [ - terraform # Terraform executable - terraform-ls # Language server - tflint # Linter - ]; }; diff --git a/modules/repositories/default.nix b/modules/repositories/default.nix new file mode 100644 index 0000000..f3cec00 --- /dev/null +++ b/modules/repositories/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + + imports = [ ./dotfiles.nix ./notes.nix ]; + +} diff --git a/modules/repositories/dotfiles.nix b/modules/repositories/dotfiles.nix index 3a21f78..edfdc5d 100644 --- a/modules/repositories/dotfiles.nix +++ b/modules/repositories/dotfiles.nix @@ -1,24 +1,30 @@ { config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles."; - home.activation = { + config = lib.mkIf config.dotfiles.enable { - # Always clone dotfiles repository if it doesn't exist - cloneDotfiles = - config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "writeBoundary" ] '' - if [ ! -d "${config.dotfilesPath}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") - $DRY_RUN_CMD ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" - fi - ''; + home-manager.users.${config.user} = { + + home.activation = { + + # Always clone dotfiles repository if it doesn't exist + cloneDotfiles = + config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' + if [ ! -d "${config.dotfilesPath}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") + $DRY_RUN_CMD ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" + fi + ''; + + }; + + # Set a variable for dotfiles repo, not necessary but convenient + home.sessionVariables.DOTS = config.dotfilesPath; }; - # Set a variable for dotfiles repo, not necessary but convenient - home.sessionVariables.DOTS = config.dotfilesPath; - }; } diff --git a/modules/services/backups.nix b/modules/services/backups.nix index f07539b..83f4b4b 100644 --- a/modules/services/backups.nix +++ b/modules/services/backups.nix @@ -1,21 +1,22 @@ { config, pkgs, lib, ... }: { - imports = [ ./secrets.nix ]; - options = { - backupS3 = { + backup.s3 = { endpoint = lib.mkOption { type = lib.types.str; description = "S3 endpoint for backups"; + default = null; }; bucket = lib.mkOption { type = lib.types.str; description = "S3 bucket for backups"; + default = null; }; accessKeyId = lib.mkOption { type = lib.types.str; description = "S3 access key ID for backups"; + default = null; }; }; diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix index 017abd8..bac9b26 100644 --- a/modules/services/caddy.nix +++ b/modules/services/caddy.nix @@ -1,18 +1,20 @@ { config, pkgs, lib, ... }: { options = { - caddyRoutes = lib.mkOption { + caddy.enable = lib.mkEnableOption "Caddy reverse proxy."; + caddy.routes = lib.mkOption { type = lib.types.listOf lib.types.attrs; description = "Caddy JSON routes for http servers"; + default = [ ]; }; - caddyBlocks = lib.mkOption { + caddy.blocks = lib.mkOption { type = lib.types.listOf lib.types.attrs; description = "Caddy JSON error blocks for http servers"; default = [ ]; }; }; - config = { + config = lib.mkIf (config.caddy.enable && config.caddy.routes != [ ]) { services.caddy = { enable = true; @@ -20,8 +22,8 @@ configFile = pkgs.writeText "Caddyfile" (builtins.toJSON { apps.http.servers.main = { listen = [ ":443" ]; - routes = config.caddyRoutes; - errors.routes = config.caddyBlocks; + routes = config.caddy.routes; + errors.routes = config.caddy.blocks; }; }); diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index fdb9b61..a4cb169 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -1,15 +1,14 @@ { config, pkgs, lib, ... }: { - imports = [ ./caddy.nix ./backups.nix ]; - options = { bookServer = lib.mkOption { type = lib.types.str; description = "Hostname for Calibre library"; + default = null; }; }; - config = { + config = lib.mkIf config.bookServer != null { services.calibre-web = { enable = true; @@ -31,7 +30,7 @@ }) ]; - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.bookServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/services/cloudflare.nix b/modules/services/cloudflare.nix index a743886..aac2582 100644 --- a/modules/services/cloudflare.nix +++ b/modules/services/cloudflare.nix @@ -1,6 +1,6 @@ # This module is necessary for hosts that are serving through Cloudflare. -{ ... }: +{ config, lib, ... }: let @@ -36,12 +36,12 @@ let in { - imports = [ ./caddy.nix ]; + options.cloudflare.enable = lib.mkEnableOption "Use Cloudflare."; - config = { + config = lib.mkIf config.cloudflare.enable { # Forces Caddy to error if coming from a non-Cloudflare IP - caddyBlocks = [{ + caddy.blocks = [{ match = [{ not = [{ remote_ip.ranges = cloudflareIpRanges; }]; }]; handle = [{ handler = "static_response"; diff --git a/modules/services/default.nix b/modules/services/default.nix new file mode 100644 index 0000000..9eb1d56 --- /dev/null +++ b/modules/services/default.nix @@ -0,0 +1,25 @@ +{ ... }: { + + imports = [ + ./backups.nix + ./caddy.nix + ./calibre.nix + ./cloudflare.nix + ./gitea.nix + ./gnupg.nix + ./honeypot.nix + ./jellyfin.nix + ./keybase.nix + ./mullvad.nix + ./n8n.nix + ./netdata.nix + ./nextcloud.nix + ./prometheus.nix + ./secrets.nix + ./sshd.nix + ./transmission.nix + ./vaultwarden.nix + ./wireguard.nix + ]; + +} diff --git a/modules/services/gitea.nix b/modules/services/gitea.nix index abdee2d..82893e1 100644 --- a/modules/services/gitea.nix +++ b/modules/services/gitea.nix @@ -4,18 +4,17 @@ let giteaPath = "/var/lib/gitea"; # Default service directory in { - imports = [ ./caddy.nix ./backups.nix ]; - options = { giteaServer = lib.mkOption { description = "Hostname for Gitea."; type = lib.types.str; + default = null; }; }; - config = { + config = lib.mkIf config.giteaServer != null { services.gitea = { enable = true; httpPort = 3001; @@ -47,7 +46,7 @@ in { networking.firewall.allowedTCPPorts = [ 122 ]; - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.giteaServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/services/gnupg.nix b/modules/services/gnupg.nix index d36f262..5324c39 100644 --- a/modules/services/gnupg.nix +++ b/modules/services/gnupg.nix @@ -1,6 +1,8 @@ { config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.gpg.enable = lib.mkEnableOption "GnuPG encryption."; + + home-manager.users.${config.user} = lib.mkIf config.gpg.enable { programs.gpg.enable = true; services.gpg-agent = { enable = true; diff --git a/modules/services/honeypot.nix b/modules/services/honeypot.nix index b8e79b6..c298e30 100644 --- a/modules/services/honeypot.nix +++ b/modules/services/honeypot.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: # Currently has some issues that don't make this viable. @@ -38,7 +38,9 @@ let in { - networking.firewall = { + options.honeypot.enable = lib.mkEnableOption "Honeypot fail2ban system."; + + networking.firewall = lib.mkIf config.honeypot.enable { extraPackages = [ pkgs.ipset ]; # allowedTCPPorts = portsToBlock; diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index eaf62bc..ffb0587 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -4,14 +4,15 @@ streamServer = lib.mkOption { type = lib.types.str; description = "Hostname for Jellyfin library"; + default = null; }; }; - config = { + config = lib.mkIf config.streamServer != null { services.jellyfin.enable = true; - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.streamServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/services/keybase.nix b/modules/services/keybase.nix index a30fc70..220495d 100644 --- a/modules/services/keybase.nix +++ b/modules/services/keybase.nix @@ -1,28 +1,34 @@ { config, pkgs, lib, ... }: { - services.keybase.enable = true; - services.kbfs = { - enable = true; - # enableRedirector = true; - mountPoint = "/run/user/1000/keybase/kbfs"; - }; - security.wrappers.keybase-redirector = { - setuid = true; - owner = "root"; - group = "root"; - source = "${pkgs.kbfs}/bin/redirector"; - }; + options.keybase.enable = lib.mkEnableOption "Keybase."; - home-manager.users.${config.user} = { - home.packages = [ (lib.mkIf config.gui.enable pkgs.keybase-gui) ]; - home.file = let - ignorePatterns = '' - keybase/ - kbfs/''; - in { - ".rgignore".text = ignorePatterns; - ".fdignore".text = ignorePatterns; + config = lib.mkIf config.keybase.enable { + + services.keybase.enable = true; + services.kbfs = { + enable = true; + # enableRedirector = true; + mountPoint = "/run/user/1000/keybase/kbfs"; }; + security.wrappers.keybase-redirector = { + setuid = true; + owner = "root"; + group = "root"; + source = "${pkgs.kbfs}/bin/redirector"; + }; + + home-manager.users.${config.user} = { + home.packages = [ (lib.mkIf config.gui.enable pkgs.keybase-gui) ]; + home.file = let + ignorePatterns = '' + keybase/ + kbfs/''; + in { + ".rgignore".text = ignorePatterns; + ".fdignore".text = ignorePatterns; + }; + }; + }; } diff --git a/modules/services/mullvad.nix b/modules/services/mullvad.nix index bdf844e..ca97d0e 100644 --- a/modules/services/mullvad.nix +++ b/modules/services/mullvad.nix @@ -1,6 +1,12 @@ -{ pkgs, ... }: { +{ config, pkgs, lib, ... }: { - services.mullvad-vpn.enable = true; - environment.systemPackages = [ pkgs.mullvad-vpn ]; + options.mullvad.enable = lib.mkEnableOption "Mullvad VPN."; + + config = lib.mkIf config.mullvad.enable { + + services.mullvad-vpn.enable = true; + environment.systemPackages = [ pkgs.mullvad-vpn ]; + + }; } diff --git a/modules/services/n8n.nix b/modules/services/n8n.nix index fe0c5ea..5bc73db 100644 --- a/modules/services/n8n.nix +++ b/modules/services/n8n.nix @@ -1,21 +1,33 @@ -{ ... }: { +{ config, pkgs, lib, ... }: { - services.n8n = { - enable = true; - settings = { - n8n = { - listenAddress = "127.0.0.1"; - port = 5678; - }; + options = { + n8nServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for n8n automation"; + default = null; }; }; - caddyRoutes = [{ - match = [{ host = [ config.n8nServer ]; }]; - handle = [{ - handler = "reverse_proxy"; - upstreams = [{ dial = "localhost:5678"; }]; + config = lib.mkIf config.n8nServer != null { + + services.n8n = { + enable = true; + settings = { + n8n = { + listenAddress = "127.0.0.1"; + port = 5678; + }; + }; + }; + + caddy.routes = [{ + match = [{ host = [ config.n8nServer ]; }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:5678"; }]; + }]; }]; - }]; + + }; } diff --git a/modules/services/netdata.nix b/modules/services/netdata.nix index cc14d8d..5082c4c 100644 --- a/modules/services/netdata.nix +++ b/modules/services/netdata.nix @@ -1,6 +1,8 @@ { config, pkgs, lib, ... }: { - config = { + options.netdata.enable = lib.mkEnableOption "Netdata metrics."; + + config = lib.mkIf config.netdata.enable { services.netdata = { enable = true; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 5feb598..f1c9b28 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -1,17 +1,16 @@ { config, pkgs, lib, ... }: { - imports = [ ./caddy.nix ./secrets.nix ./backups.nix ]; - options = { nextcloudServer = lib.mkOption { type = lib.types.str; description = "Hostname for Nextcloud"; + default = null; }; }; - config = { + config = lib.mkIf config.nextcloudServer != null { services.nextcloud = { enable = true; @@ -32,7 +31,7 @@ }]; # Point Caddy to Nginx - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.nextcloudServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/services/prometheus.nix b/modules/services/prometheus.nix index 15e91ee..495aaad 100644 --- a/modules/services/prometheus.nix +++ b/modules/services/prometheus.nix @@ -3,9 +3,10 @@ options.metricsServer = lib.mkOption { type = lib.types.str; description = "Hostname of the Grafana server."; + default = null; }; - config = { + config = lib.mkIf config.metricsServer != null { services.grafana.enable = true; @@ -21,7 +22,7 @@ }]; }; - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.metricsServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/services/secrets.nix b/modules/services/secrets.nix index d596c70..0a8ff7f 100644 --- a/modules/services/secrets.nix +++ b/modules/services/secrets.nix @@ -47,7 +47,7 @@ }; - config = { + config = lib.mkIf (pkgs.stdenv.isLinux && !config.wsl.enable) { # Create a default directory to place secrets diff --git a/modules/services/sshd.nix b/modules/services/sshd.nix index 099589e..9eb4265 100644 --- a/modules/services/sshd.nix +++ b/modules/services/sshd.nix @@ -12,7 +12,7 @@ }; }; - config = { + config = lib.mkIf (pkgs.stdenv.isLinux && !config.wsl.enable) { services.openssh = { enable = true; ports = [ 22 ]; diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 8c7e667..a1bbd7e 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -1,11 +1,10 @@ { config, pkgs, lib, ... }: { - imports = [ ./wireguard.nix ./secrets.nix ]; - options = { transmissionServer = lib.mkOption { type = lib.types.str; description = "Hostname for Transmission"; + default = null; }; }; @@ -13,7 +12,7 @@ namespace = config.networking.wireguard.interfaces.wg0.interfaceNamespace; vpnIp = lib.strings.removeSuffix "/32" (builtins.head config.networking.wireguard.interfaces.wg0.ips); - in { + in lib.mkIf (config.wireguard.enable && config.transmissionServer != null) { # Setup transmission services.transmission = { diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index d9cf20f..b9a3e28 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -4,18 +4,17 @@ let vaultwardenPath = "/var/lib/bitwarden_rs"; # Default service directory in { - imports = [ ./caddy.nix ./secrets.nix ./backups.nix ]; - options = { vaultwardenServer = lib.mkOption { description = "Hostname for Vaultwarden."; type = lib.types.str; + default = null; }; }; - config = { + config = lib.mkIf config.vaultwardenServer != null { services.vaultwarden = { enable = true; config = { diff --git a/modules/services/wireguard.nix b/modules/services/wireguard.nix index 9b1003d..1701f26 100644 --- a/modules/services/wireguard.nix +++ b/modules/services/wireguard.nix @@ -1,8 +1,8 @@ { config, pkgs, lib, ... }: { - imports = [ ./secrets.nix ]; + options.wireguard.enable = lib.mkEnableOption "Wireguard VPN setup."; - config = { + config = lib.mkIf (pkgs.stdenv.isLinux && config.wireguard.enable) { networking.wireguard = { enable = true; diff --git a/modules/shell/charm.nix b/modules/shell/charm.nix index 4cdd071..2a22fd1 100644 --- a/modules/shell/charm.nix +++ b/modules/shell/charm.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { - home-manager.users.${config.user} = { + options.charm.enable = lib.mkEnableOption "Charm utilities."; + + home-manager.users.${config.user} = lib.mkIf config.charm.enable { home.packages = with pkgs; [ glow # Markdown previews diff --git a/modules/wsl/default.nix b/modules/wsl/default.nix index 73c04ba..a9b1240 100644 --- a/modules/wsl/default.nix +++ b/modules/wsl/default.nix @@ -1,19 +1,23 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { - # Systemd doesn't work in WSL so these must be disabled - services.geoclue2.enable = lib.mkForce false; - location = { provider = lib.mkForce "manual"; }; - services.localtimed.enable = lib.mkForce false; + config = lib.mkIf (pkgs.stdenv.isLinux && config.wsl.enable) { - # Used by NeoVim for clipboard sharing with Windows - # home-manager.users.${config.user}.home.sessionPath = - # [ "/mnt/c/Program Files/win32yank/" ]; + # Systemd doesn't work in WSL so these must be disabled + services.geoclue2.enable = lib.mkForce false; + location = { provider = lib.mkForce "manual"; }; + services.localtimed.enable = lib.mkForce false; - # Replace config directory with our repo, since it sources from config on - # every launch - system.activationScripts.configDir.text = '' - rm -rf /etc/nixos - ln --symbolic --no-dereference --force ${config.dotfilesPath} /etc/nixos - ''; + # Used by NeoVim for clipboard sharing with Windows + # home-manager.users.${config.user}.home.sessionPath = + # [ "/mnt/c/Program Files/win32yank/" ]; + + # Replace config directory with our repo, since it sources from config on + # every launch + system.activationScripts.configDir.text = '' + rm -rf /etc/nixos + ln --symbolic --no-dereference --force ${config.dotfilesPath} /etc/nixos + ''; + + }; } From 7063bd5f7a2ad4d1914729e740cc71179085d8ae Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 21 Dec 2022 14:38:34 -0700 Subject: [PATCH 161/391] fixes for module layout --- modules/darwin/tmux.nix | 2 +- modules/services/calibre.nix | 2 +- modules/services/gitea.nix | 2 +- modules/services/gnupg.nix | 2 +- modules/services/honeypot.nix | 2 +- modules/services/jellyfin.nix | 2 +- modules/services/n8n.nix | 2 +- modules/services/nextcloud.nix | 2 +- modules/services/prometheus.nix | 2 +- modules/services/transmission.nix | 2 +- modules/services/vaultwarden.nix | 4 ++-- modules/shell/charm.nix | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/darwin/tmux.nix b/modules/darwin/tmux.nix index 95b585a..252e70e 100644 --- a/modules/darwin/tmux.nix +++ b/modules/darwin/tmux.nix @@ -2,7 +2,7 @@ options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer"; - home-manager.users.${config.user} = lib.mkIf config.tmux.enable { + config.home-manager.users.${config.user} = lib.mkIf config.tmux.enable { programs.tmux = { enable = true; diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index a4cb169..a3365e0 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -8,7 +8,7 @@ }; }; - config = lib.mkIf config.bookServer != null { + config = lib.mkIf (config.bookServer != null) { services.calibre-web = { enable = true; diff --git a/modules/services/gitea.nix b/modules/services/gitea.nix index 82893e1..4810279 100644 --- a/modules/services/gitea.nix +++ b/modules/services/gitea.nix @@ -14,7 +14,7 @@ in { }; - config = lib.mkIf config.giteaServer != null { + config = lib.mkIf (config.giteaServer != null) { services.gitea = { enable = true; httpPort = 3001; diff --git a/modules/services/gnupg.nix b/modules/services/gnupg.nix index 5324c39..f4f3ca0 100644 --- a/modules/services/gnupg.nix +++ b/modules/services/gnupg.nix @@ -2,7 +2,7 @@ options.gpg.enable = lib.mkEnableOption "GnuPG encryption."; - home-manager.users.${config.user} = lib.mkIf config.gpg.enable { + config.home-manager.users.${config.user} = lib.mkIf config.gpg.enable { programs.gpg.enable = true; services.gpg-agent = { enable = true; diff --git a/modules/services/honeypot.nix b/modules/services/honeypot.nix index c298e30..8c109a4 100644 --- a/modules/services/honeypot.nix +++ b/modules/services/honeypot.nix @@ -40,7 +40,7 @@ in { options.honeypot.enable = lib.mkEnableOption "Honeypot fail2ban system."; - networking.firewall = lib.mkIf config.honeypot.enable { + config.networking.firewall = lib.mkIf config.honeypot.enable { extraPackages = [ pkgs.ipset ]; # allowedTCPPorts = portsToBlock; diff --git a/modules/services/jellyfin.nix b/modules/services/jellyfin.nix index ffb0587..4b8bb21 100644 --- a/modules/services/jellyfin.nix +++ b/modules/services/jellyfin.nix @@ -8,7 +8,7 @@ }; }; - config = lib.mkIf config.streamServer != null { + config = lib.mkIf (config.streamServer != null) { services.jellyfin.enable = true; diff --git a/modules/services/n8n.nix b/modules/services/n8n.nix index 5bc73db..f06b1d6 100644 --- a/modules/services/n8n.nix +++ b/modules/services/n8n.nix @@ -8,7 +8,7 @@ }; }; - config = lib.mkIf config.n8nServer != null { + config = lib.mkIf (config.n8nServer != null) { services.n8n = { enable = true; diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index f1c9b28..fd1a01c 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -10,7 +10,7 @@ }; - config = lib.mkIf config.nextcloudServer != null { + config = lib.mkIf (config.nextcloudServer != null) { services.nextcloud = { enable = true; diff --git a/modules/services/prometheus.nix b/modules/services/prometheus.nix index 495aaad..d8adb2f 100644 --- a/modules/services/prometheus.nix +++ b/modules/services/prometheus.nix @@ -6,7 +6,7 @@ default = null; }; - config = lib.mkIf config.metricsServer != null { + config = lib.mkIf (config.metricsServer != null) { services.grafana.enable = true; diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index a1bbd7e..fc805c1 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -41,7 +41,7 @@ }; # Create reverse proxy for web UI - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.transmissionServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index b9a3e28..c547dea 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -14,7 +14,7 @@ in { }; - config = lib.mkIf config.vaultwardenServer != null { + config = lib.mkIf (config.vaultwardenServer != null) { services.vaultwarden = { enable = true; config = { @@ -46,7 +46,7 @@ in { networking.firewall.allowedTCPPorts = [ 3012 ]; - caddyRoutes = [{ + caddy.routes = [{ match = [{ host = [ config.vaultwardenServer ]; }]; handle = [{ handler = "reverse_proxy"; diff --git a/modules/shell/charm.nix b/modules/shell/charm.nix index 2a22fd1..b2972cf 100644 --- a/modules/shell/charm.nix +++ b/modules/shell/charm.nix @@ -2,7 +2,7 @@ options.charm.enable = lib.mkEnableOption "Charm utilities."; - home-manager.users.${config.user} = lib.mkIf config.charm.enable { + config.home-manager.users.${config.user} = lib.mkIf config.charm.enable { home.packages = with pkgs; [ glow # Markdown previews From d021baa1bb1dbaf8b60c56b918419bfb0fe5fa1d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:07:58 -0700 Subject: [PATCH 162/391] split nixos from darwin required because they don't share all attributes --- {modules/darwin => darwin}/alacritty.nix | 0 {modules/darwin => darwin}/default.nix | 0 {modules/darwin => darwin}/fonts.nix | 0 {modules/darwin => darwin}/hammerspoon.nix | 0 .../darwin => darwin}/hammerspoon/.stylua.toml | 0 .../Spoons/ControlEscape.spoon/init.lua | 0 .../close_notifications_applescript.js | 0 .../Spoons/DismissAlerts.spoon/init.lua | 0 .../hammerspoon/Spoons/Launcher.spoon/init.lua | 0 .../Spoons/MoveWindow.spoon/init.lua | 0 .../Spoons/MoveWindow.spoon/worklayout.lua | 0 {modules/darwin => darwin}/hammerspoon/init.lua | 0 {modules/darwin => darwin}/homebrew.nix | 0 {modules/darwin => darwin}/kitty.nix | 0 {modules/darwin => darwin}/networking.nix | 0 {modules/darwin => darwin}/nixpkgs.nix | 0 {modules/darwin => darwin}/system.nix | 0 {modules/darwin => darwin}/tmux.nix | 0 {modules/darwin => darwin}/user.nix | 0 {modules/darwin => darwin}/utilities.nix | 2 +- hosts/desktop/default.nix | 6 +++--- hosts/macbook/default.nix | 2 +- hosts/oracle/default.nix | 1 + hosts/wsl/default.nix | 1 + modules/applications/default.nix | 1 - modules/default.nix | 17 ++--------------- {modules => nixos}/applications/calibre.nix | 0 nixos/default.nix | 13 +++++++++++++ {modules => nixos}/gaming/default.nix | 0 {modules => nixos}/gaming/leagueoflegends.nix | 0 {modules => nixos}/gaming/legendary.nix | 0 {modules => nixos}/gaming/lutris.nix | 0 {modules => nixos}/gaming/minecraft-server.nix | 0 {modules => nixos}/gaming/steam.nix | 0 {modules => nixos}/graphical/default.nix | 0 {modules => nixos}/graphical/dmenu.nix | 0 {modules => nixos}/graphical/fonts.nix | 0 {modules => nixos}/graphical/i3.nix | 0 {modules => nixos}/graphical/picom.nix | 0 {modules => nixos}/graphical/polybar.nix | 0 {modules => nixos}/graphical/rofi.nix | 0 {modules => nixos}/graphical/rofi/brightness.sh | 0 {modules => nixos}/graphical/xorg.nix | 0 {modules => nixos}/hardware/audio.nix | 0 {modules => nixos}/hardware/boot.nix | 0 {modules => nixos}/hardware/default.nix | 0 {modules => nixos}/hardware/keyboard.nix | 0 {modules => nixos}/hardware/monitors.nix | 0 {modules => nixos}/hardware/mouse.nix | 0 {modules => nixos}/hardware/networking.nix | 0 {modules => nixos}/hardware/server.nix | 0 {modules => nixos}/hardware/sleep.nix | 0 {modules => nixos}/hardware/wifi.nix | 0 {modules => nixos}/services/backups.nix | 0 {modules => nixos}/services/caddy.nix | 0 {modules => nixos}/services/calibre.nix | 0 {modules => nixos}/services/cloudflare.nix | 0 {modules => nixos}/services/default.nix | 0 {modules => nixos}/services/gitea.nix | 0 {modules => nixos}/services/gnupg.nix | 0 {modules => nixos}/services/honeypot.nix | 0 {modules => nixos}/services/jellyfin.nix | 0 {modules => nixos}/services/keybase.nix | 0 {modules => nixos}/services/mullvad.nix | 0 {modules => nixos}/services/n8n.nix | 0 {modules => nixos}/services/netdata.nix | 0 {modules => nixos}/services/nextcloud.nix | 0 {modules => nixos}/services/prometheus.nix | 0 {modules => nixos}/services/secrets.nix | 0 {modules => nixos}/services/sshd.nix | 0 {modules => nixos}/services/transmission.nix | 0 {modules => nixos}/services/vaultwarden.nix | 0 {modules => nixos}/services/wireguard.nix | 0 {modules/nixos => nixos/system}/default.nix | 0 {modules/nixos => nixos/system}/doas.nix | 0 {modules/nixos => nixos/system}/timezone.nix | 0 {modules/nixos => nixos/system}/user.nix | 0 {modules => nixos}/wsl/default.nix | 0 78 files changed, 22 insertions(+), 21 deletions(-) rename {modules/darwin => darwin}/alacritty.nix (100%) rename {modules/darwin => darwin}/default.nix (100%) rename {modules/darwin => darwin}/fonts.nix (100%) rename {modules/darwin => darwin}/hammerspoon.nix (100%) rename {modules/darwin => darwin}/hammerspoon/.stylua.toml (100%) rename {modules/darwin => darwin}/hammerspoon/Spoons/ControlEscape.spoon/init.lua (100%) rename {modules/darwin => darwin}/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js (100%) rename {modules/darwin => darwin}/hammerspoon/Spoons/DismissAlerts.spoon/init.lua (100%) rename {modules/darwin => darwin}/hammerspoon/Spoons/Launcher.spoon/init.lua (100%) rename {modules/darwin => darwin}/hammerspoon/Spoons/MoveWindow.spoon/init.lua (100%) rename {modules/darwin => darwin}/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua (100%) rename {modules/darwin => darwin}/hammerspoon/init.lua (100%) rename {modules/darwin => darwin}/homebrew.nix (100%) rename {modules/darwin => darwin}/kitty.nix (100%) rename {modules/darwin => darwin}/networking.nix (100%) rename {modules/darwin => darwin}/nixpkgs.nix (100%) rename {modules/darwin => darwin}/system.nix (100%) rename {modules/darwin => darwin}/tmux.nix (100%) rename {modules/darwin => darwin}/user.nix (100%) rename {modules/darwin => darwin}/utilities.nix (96%) rename {modules => nixos}/applications/calibre.nix (100%) create mode 100644 nixos/default.nix rename {modules => nixos}/gaming/default.nix (100%) rename {modules => nixos}/gaming/leagueoflegends.nix (100%) rename {modules => nixos}/gaming/legendary.nix (100%) rename {modules => nixos}/gaming/lutris.nix (100%) rename {modules => nixos}/gaming/minecraft-server.nix (100%) rename {modules => nixos}/gaming/steam.nix (100%) rename {modules => nixos}/graphical/default.nix (100%) rename {modules => nixos}/graphical/dmenu.nix (100%) rename {modules => nixos}/graphical/fonts.nix (100%) rename {modules => nixos}/graphical/i3.nix (100%) rename {modules => nixos}/graphical/picom.nix (100%) rename {modules => nixos}/graphical/polybar.nix (100%) rename {modules => nixos}/graphical/rofi.nix (100%) rename {modules => nixos}/graphical/rofi/brightness.sh (100%) rename {modules => nixos}/graphical/xorg.nix (100%) rename {modules => nixos}/hardware/audio.nix (100%) rename {modules => nixos}/hardware/boot.nix (100%) rename {modules => nixos}/hardware/default.nix (100%) rename {modules => nixos}/hardware/keyboard.nix (100%) rename {modules => nixos}/hardware/monitors.nix (100%) rename {modules => nixos}/hardware/mouse.nix (100%) rename {modules => nixos}/hardware/networking.nix (100%) rename {modules => nixos}/hardware/server.nix (100%) rename {modules => nixos}/hardware/sleep.nix (100%) rename {modules => nixos}/hardware/wifi.nix (100%) rename {modules => nixos}/services/backups.nix (100%) rename {modules => nixos}/services/caddy.nix (100%) rename {modules => nixos}/services/calibre.nix (100%) rename {modules => nixos}/services/cloudflare.nix (100%) rename {modules => nixos}/services/default.nix (100%) rename {modules => nixos}/services/gitea.nix (100%) rename {modules => nixos}/services/gnupg.nix (100%) rename {modules => nixos}/services/honeypot.nix (100%) rename {modules => nixos}/services/jellyfin.nix (100%) rename {modules => nixos}/services/keybase.nix (100%) rename {modules => nixos}/services/mullvad.nix (100%) rename {modules => nixos}/services/n8n.nix (100%) rename {modules => nixos}/services/netdata.nix (100%) rename {modules => nixos}/services/nextcloud.nix (100%) rename {modules => nixos}/services/prometheus.nix (100%) rename {modules => nixos}/services/secrets.nix (100%) rename {modules => nixos}/services/sshd.nix (100%) rename {modules => nixos}/services/transmission.nix (100%) rename {modules => nixos}/services/vaultwarden.nix (100%) rename {modules => nixos}/services/wireguard.nix (100%) rename {modules/nixos => nixos/system}/default.nix (100%) rename {modules/nixos => nixos/system}/doas.nix (100%) rename {modules/nixos => nixos/system}/timezone.nix (100%) rename {modules/nixos => nixos/system}/user.nix (100%) rename {modules => nixos}/wsl/default.nix (100%) diff --git a/modules/darwin/alacritty.nix b/darwin/alacritty.nix similarity index 100% rename from modules/darwin/alacritty.nix rename to darwin/alacritty.nix diff --git a/modules/darwin/default.nix b/darwin/default.nix similarity index 100% rename from modules/darwin/default.nix rename to darwin/default.nix diff --git a/modules/darwin/fonts.nix b/darwin/fonts.nix similarity index 100% rename from modules/darwin/fonts.nix rename to darwin/fonts.nix diff --git a/modules/darwin/hammerspoon.nix b/darwin/hammerspoon.nix similarity index 100% rename from modules/darwin/hammerspoon.nix rename to darwin/hammerspoon.nix diff --git a/modules/darwin/hammerspoon/.stylua.toml b/darwin/hammerspoon/.stylua.toml similarity index 100% rename from modules/darwin/hammerspoon/.stylua.toml rename to darwin/hammerspoon/.stylua.toml diff --git a/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua b/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua similarity index 100% rename from modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua rename to darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js b/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js similarity index 100% rename from modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js rename to darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua b/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua similarity index 100% rename from modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua rename to darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua similarity index 100% rename from modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua rename to darwin/hammerspoon/Spoons/Launcher.spoon/init.lua diff --git a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua b/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua similarity index 100% rename from modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua rename to darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua diff --git a/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua b/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua similarity index 100% rename from modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua rename to darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua diff --git a/modules/darwin/hammerspoon/init.lua b/darwin/hammerspoon/init.lua similarity index 100% rename from modules/darwin/hammerspoon/init.lua rename to darwin/hammerspoon/init.lua diff --git a/modules/darwin/homebrew.nix b/darwin/homebrew.nix similarity index 100% rename from modules/darwin/homebrew.nix rename to darwin/homebrew.nix diff --git a/modules/darwin/kitty.nix b/darwin/kitty.nix similarity index 100% rename from modules/darwin/kitty.nix rename to darwin/kitty.nix diff --git a/modules/darwin/networking.nix b/darwin/networking.nix similarity index 100% rename from modules/darwin/networking.nix rename to darwin/networking.nix diff --git a/modules/darwin/nixpkgs.nix b/darwin/nixpkgs.nix similarity index 100% rename from modules/darwin/nixpkgs.nix rename to darwin/nixpkgs.nix diff --git a/modules/darwin/system.nix b/darwin/system.nix similarity index 100% rename from modules/darwin/system.nix rename to darwin/system.nix diff --git a/modules/darwin/tmux.nix b/darwin/tmux.nix similarity index 100% rename from modules/darwin/tmux.nix rename to darwin/tmux.nix diff --git a/modules/darwin/user.nix b/darwin/user.nix similarity index 100% rename from modules/darwin/user.nix rename to darwin/user.nix diff --git a/modules/darwin/utilities.nix b/darwin/utilities.nix similarity index 96% rename from modules/darwin/utilities.nix rename to darwin/utilities.nix index 90dd067..5f65a35 100644 --- a/modules/darwin/utilities.nix +++ b/darwin/utilities.nix @@ -34,7 +34,7 @@ in { ipcalc # Make IP network calculations (mkScript { name = "ocr"; - file = ../shell/bash/scripts/ocr.sh; + file = ../modules/shell/bash/scripts/ocr.sh; env = [ tesseract ]; }) ]; diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index c2ece6d..b1bc604 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -7,6 +7,9 @@ nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { }; modules = [ + ./hardware-configuration.nix + ../../modules + ../../nixos globals home-manager.nixosModules.home-manager { @@ -42,8 +45,5 @@ nixpkgs.lib.nixosSystem { nixlang.enable = true; dotfiles.enable = true; } - - ./hardware-configuration.nix - ../../modules ]; } diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index cd5d2da..52dec24 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -8,6 +8,7 @@ darwin.lib.darwinSystem { specialArgs = { }; modules = [ ../../modules + ../../darwin (globals // { user = "Noah.Masur"; gitName = "Noah-Masur_1701"; @@ -26,7 +27,6 @@ darwin.lib.darwinSystem { nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; - mail.aerc.enable = true; mail.himalaya.enable = true; kitty.enable = true; diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 265b03e..ad1eee5 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -13,6 +13,7 @@ nixpkgs.lib.nixosSystem { modules = [ ./hardware-configuration.nix ../../modules + ../../nixos (removeAttrs globals [ "mail.server" ]) home-manager.nixosModules.home-manager { diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index b9b8250..edfc27f 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -11,6 +11,7 @@ nixpkgs.lib.nixosSystem { wsl.nixosModules.wsl home-manager.nixosModules.home-manager ../../modules + ../../nixos { networking.hostName = "wsl"; # Set registry to flake packages, used for nix X commands diff --git a/modules/applications/default.nix b/modules/applications/default.nix index ee01e55..957b460 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -3,7 +3,6 @@ imports = [ ./1password.nix ./alacritty.nix - ./calibre.nix ./discord.nix ./firefox.nix ./kitty.nix diff --git a/modules/default.nix b/modules/default.nix index e5526b7..ce4219a 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,20 +1,7 @@ { config, lib, pkgs, ... }: { - imports = [ - ./applications - ./darwin - ./gaming - ./graphical - ./hardware - ./mail - ./neovim - ./nixos - ./programming - ./repositories - ./services - ./shell - ./wsl - ]; + imports = + [ ./applications ./mail ./neovim ./programming ./repositories ./shell ]; options = { user = lib.mkOption { diff --git a/modules/applications/calibre.nix b/nixos/applications/calibre.nix similarity index 100% rename from modules/applications/calibre.nix rename to nixos/applications/calibre.nix diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..19b0a27 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,13 @@ +{ ... }: { + + imports = [ + ./applications + ./gaming + ./graphical + ./hardware + ./services + ./system + ./wsl + ]; + +} diff --git a/modules/gaming/default.nix b/nixos/gaming/default.nix similarity index 100% rename from modules/gaming/default.nix rename to nixos/gaming/default.nix diff --git a/modules/gaming/leagueoflegends.nix b/nixos/gaming/leagueoflegends.nix similarity index 100% rename from modules/gaming/leagueoflegends.nix rename to nixos/gaming/leagueoflegends.nix diff --git a/modules/gaming/legendary.nix b/nixos/gaming/legendary.nix similarity index 100% rename from modules/gaming/legendary.nix rename to nixos/gaming/legendary.nix diff --git a/modules/gaming/lutris.nix b/nixos/gaming/lutris.nix similarity index 100% rename from modules/gaming/lutris.nix rename to nixos/gaming/lutris.nix diff --git a/modules/gaming/minecraft-server.nix b/nixos/gaming/minecraft-server.nix similarity index 100% rename from modules/gaming/minecraft-server.nix rename to nixos/gaming/minecraft-server.nix diff --git a/modules/gaming/steam.nix b/nixos/gaming/steam.nix similarity index 100% rename from modules/gaming/steam.nix rename to nixos/gaming/steam.nix diff --git a/modules/graphical/default.nix b/nixos/graphical/default.nix similarity index 100% rename from modules/graphical/default.nix rename to nixos/graphical/default.nix diff --git a/modules/graphical/dmenu.nix b/nixos/graphical/dmenu.nix similarity index 100% rename from modules/graphical/dmenu.nix rename to nixos/graphical/dmenu.nix diff --git a/modules/graphical/fonts.nix b/nixos/graphical/fonts.nix similarity index 100% rename from modules/graphical/fonts.nix rename to nixos/graphical/fonts.nix diff --git a/modules/graphical/i3.nix b/nixos/graphical/i3.nix similarity index 100% rename from modules/graphical/i3.nix rename to nixos/graphical/i3.nix diff --git a/modules/graphical/picom.nix b/nixos/graphical/picom.nix similarity index 100% rename from modules/graphical/picom.nix rename to nixos/graphical/picom.nix diff --git a/modules/graphical/polybar.nix b/nixos/graphical/polybar.nix similarity index 100% rename from modules/graphical/polybar.nix rename to nixos/graphical/polybar.nix diff --git a/modules/graphical/rofi.nix b/nixos/graphical/rofi.nix similarity index 100% rename from modules/graphical/rofi.nix rename to nixos/graphical/rofi.nix diff --git a/modules/graphical/rofi/brightness.sh b/nixos/graphical/rofi/brightness.sh similarity index 100% rename from modules/graphical/rofi/brightness.sh rename to nixos/graphical/rofi/brightness.sh diff --git a/modules/graphical/xorg.nix b/nixos/graphical/xorg.nix similarity index 100% rename from modules/graphical/xorg.nix rename to nixos/graphical/xorg.nix diff --git a/modules/hardware/audio.nix b/nixos/hardware/audio.nix similarity index 100% rename from modules/hardware/audio.nix rename to nixos/hardware/audio.nix diff --git a/modules/hardware/boot.nix b/nixos/hardware/boot.nix similarity index 100% rename from modules/hardware/boot.nix rename to nixos/hardware/boot.nix diff --git a/modules/hardware/default.nix b/nixos/hardware/default.nix similarity index 100% rename from modules/hardware/default.nix rename to nixos/hardware/default.nix diff --git a/modules/hardware/keyboard.nix b/nixos/hardware/keyboard.nix similarity index 100% rename from modules/hardware/keyboard.nix rename to nixos/hardware/keyboard.nix diff --git a/modules/hardware/monitors.nix b/nixos/hardware/monitors.nix similarity index 100% rename from modules/hardware/monitors.nix rename to nixos/hardware/monitors.nix diff --git a/modules/hardware/mouse.nix b/nixos/hardware/mouse.nix similarity index 100% rename from modules/hardware/mouse.nix rename to nixos/hardware/mouse.nix diff --git a/modules/hardware/networking.nix b/nixos/hardware/networking.nix similarity index 100% rename from modules/hardware/networking.nix rename to nixos/hardware/networking.nix diff --git a/modules/hardware/server.nix b/nixos/hardware/server.nix similarity index 100% rename from modules/hardware/server.nix rename to nixos/hardware/server.nix diff --git a/modules/hardware/sleep.nix b/nixos/hardware/sleep.nix similarity index 100% rename from modules/hardware/sleep.nix rename to nixos/hardware/sleep.nix diff --git a/modules/hardware/wifi.nix b/nixos/hardware/wifi.nix similarity index 100% rename from modules/hardware/wifi.nix rename to nixos/hardware/wifi.nix diff --git a/modules/services/backups.nix b/nixos/services/backups.nix similarity index 100% rename from modules/services/backups.nix rename to nixos/services/backups.nix diff --git a/modules/services/caddy.nix b/nixos/services/caddy.nix similarity index 100% rename from modules/services/caddy.nix rename to nixos/services/caddy.nix diff --git a/modules/services/calibre.nix b/nixos/services/calibre.nix similarity index 100% rename from modules/services/calibre.nix rename to nixos/services/calibre.nix diff --git a/modules/services/cloudflare.nix b/nixos/services/cloudflare.nix similarity index 100% rename from modules/services/cloudflare.nix rename to nixos/services/cloudflare.nix diff --git a/modules/services/default.nix b/nixos/services/default.nix similarity index 100% rename from modules/services/default.nix rename to nixos/services/default.nix diff --git a/modules/services/gitea.nix b/nixos/services/gitea.nix similarity index 100% rename from modules/services/gitea.nix rename to nixos/services/gitea.nix diff --git a/modules/services/gnupg.nix b/nixos/services/gnupg.nix similarity index 100% rename from modules/services/gnupg.nix rename to nixos/services/gnupg.nix diff --git a/modules/services/honeypot.nix b/nixos/services/honeypot.nix similarity index 100% rename from modules/services/honeypot.nix rename to nixos/services/honeypot.nix diff --git a/modules/services/jellyfin.nix b/nixos/services/jellyfin.nix similarity index 100% rename from modules/services/jellyfin.nix rename to nixos/services/jellyfin.nix diff --git a/modules/services/keybase.nix b/nixos/services/keybase.nix similarity index 100% rename from modules/services/keybase.nix rename to nixos/services/keybase.nix diff --git a/modules/services/mullvad.nix b/nixos/services/mullvad.nix similarity index 100% rename from modules/services/mullvad.nix rename to nixos/services/mullvad.nix diff --git a/modules/services/n8n.nix b/nixos/services/n8n.nix similarity index 100% rename from modules/services/n8n.nix rename to nixos/services/n8n.nix diff --git a/modules/services/netdata.nix b/nixos/services/netdata.nix similarity index 100% rename from modules/services/netdata.nix rename to nixos/services/netdata.nix diff --git a/modules/services/nextcloud.nix b/nixos/services/nextcloud.nix similarity index 100% rename from modules/services/nextcloud.nix rename to nixos/services/nextcloud.nix diff --git a/modules/services/prometheus.nix b/nixos/services/prometheus.nix similarity index 100% rename from modules/services/prometheus.nix rename to nixos/services/prometheus.nix diff --git a/modules/services/secrets.nix b/nixos/services/secrets.nix similarity index 100% rename from modules/services/secrets.nix rename to nixos/services/secrets.nix diff --git a/modules/services/sshd.nix b/nixos/services/sshd.nix similarity index 100% rename from modules/services/sshd.nix rename to nixos/services/sshd.nix diff --git a/modules/services/transmission.nix b/nixos/services/transmission.nix similarity index 100% rename from modules/services/transmission.nix rename to nixos/services/transmission.nix diff --git a/modules/services/vaultwarden.nix b/nixos/services/vaultwarden.nix similarity index 100% rename from modules/services/vaultwarden.nix rename to nixos/services/vaultwarden.nix diff --git a/modules/services/wireguard.nix b/nixos/services/wireguard.nix similarity index 100% rename from modules/services/wireguard.nix rename to nixos/services/wireguard.nix diff --git a/modules/nixos/default.nix b/nixos/system/default.nix similarity index 100% rename from modules/nixos/default.nix rename to nixos/system/default.nix diff --git a/modules/nixos/doas.nix b/nixos/system/doas.nix similarity index 100% rename from modules/nixos/doas.nix rename to nixos/system/doas.nix diff --git a/modules/nixos/timezone.nix b/nixos/system/timezone.nix similarity index 100% rename from modules/nixos/timezone.nix rename to nixos/system/timezone.nix diff --git a/modules/nixos/user.nix b/nixos/system/user.nix similarity index 100% rename from modules/nixos/user.nix rename to nixos/system/user.nix diff --git a/modules/wsl/default.nix b/nixos/wsl/default.nix similarity index 100% rename from modules/wsl/default.nix rename to nixos/wsl/default.nix From b4ddb149cc8ed35c5c4ccd1d9ee88478e334031b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 22 Dec 2022 00:31:25 +0000 Subject: [PATCH 163/391] fix: bad references for server linux --- hosts/desktop/default.nix | 3 +++ hosts/macbook/default.nix | 1 + hosts/oracle/default.nix | 2 ++ hosts/wsl/default.nix | 5 +++-- modules/mail/default.nix | 3 ++- nixos/applications/default.nix | 5 +++++ nixos/graphical/xorg.nix | 2 +- nixos/hardware/monitors.nix | 3 --- nixos/services/backups.nix | 6 +++--- nixos/services/calibre.nix | 6 +++--- nixos/services/gitea.nix | 2 +- nixos/services/n8n.nix | 2 +- nixos/services/nextcloud.nix | 2 +- nixos/services/vaultwarden.nix | 8 ++++---- 14 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 nixos/applications/default.nix diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index b1bc604..38f383f 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -11,6 +11,7 @@ nixpkgs.lib.nixosSystem { ../../modules ../../nixos globals + wsl.nixosModules.wsl home-manager.nixosModules.home-manager { physical = true; @@ -27,6 +28,7 @@ nixpkgs.lib.nixosSystem { wallpaper = "${wallpapers}/gruvbox/road.jpg"; gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; + wsl.enable = false; media.enable = true; firefox.enable = true; @@ -35,6 +37,7 @@ nixpkgs.lib.nixosSystem { discord.enable = true; nautilus.enable = true; obsidian.enable = true; + mail.enable = true; mail.aerc.enable = true; mail.himalaya.enable = true; gaming.enable = true; diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 52dec24..0c23455 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -27,6 +27,7 @@ darwin.lib.darwinSystem { nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; + mail.enable = true; mail.aerc.enable = true; mail.himalaya.enable = true; kitty.enable = true; diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index ad1eee5..35df13a 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -15,12 +15,14 @@ nixpkgs.lib.nixosSystem { ../../modules ../../nixos (removeAttrs globals [ "mail.server" ]) + wsl.nixosModules.wsl home-manager.nixosModules.home-manager { server = true; gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; + wsl.enable = false; # FQDNs for various services networking.hostName = "oracle"; diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index edfc27f..e076c60 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -7,11 +7,11 @@ nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { }; modules = [ + ../../modules + ../../nixos globals wsl.nixosModules.wsl home-manager.nixosModules.home-manager - ../../modules - ../../nixos { networking.hostName = "wsl"; # Set registry to flake packages, used for nix X commands @@ -33,6 +33,7 @@ nixpkgs.lib.nixosSystem { false; # Including Windows PATH will slow down Neovim command mode }; + mail.enable = true; mail.aerc.enable = true; mail.himalaya.enable = true; dotfiles.enable = true; diff --git a/modules/mail/default.nix b/modules/mail/default.nix index 24ac7e1..2afa517 100644 --- a/modules/mail/default.nix +++ b/modules/mail/default.nix @@ -3,6 +3,7 @@ imports = [ ./himalaya.nix ./aerc.nix ]; options = { + mail.enable = lib.mkEnableOption "Mail service."; mail.user = lib.mkOption { type = lib.types.str; description = "User name for the email address."; @@ -14,7 +15,7 @@ }; }; - config = lib.mkIf (config.mail.user != null && config.mail.server != null) { + config = lib.mkIf config.mail.enable { home-manager.users.${config.user} = { programs.mbsync = { enable = true; }; diff --git a/nixos/applications/default.nix b/nixos/applications/default.nix new file mode 100644 index 0000000..18b746c --- /dev/null +++ b/nixos/applications/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + + imports = [ ./calibre.nix ]; + +} diff --git a/nixos/graphical/xorg.nix b/nixos/graphical/xorg.nix index fab1510..53f4d0e 100644 --- a/nixos/graphical/xorg.nix +++ b/nixos/graphical/xorg.nix @@ -21,7 +21,7 @@ package = pkgs."${config.gtk.theme.package}"; }; - in lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) { + in lib.mkIf config.gui.enable { # Enable the X11 windowing system. services.xserver = { diff --git a/nixos/hardware/monitors.nix b/nixos/hardware/monitors.nix index 297c475..e8cf5b9 100644 --- a/nixos/hardware/monitors.nix +++ b/nixos/hardware/monitors.nix @@ -1,8 +1,5 @@ { config, pkgs, lib, ... }: { - # Timezone required for Redshift schedule - imports = [ ../nixos/timezone.nix ]; - config = lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) { diff --git a/nixos/services/backups.nix b/nixos/services/backups.nix index 83f4b4b..5c25048 100644 --- a/nixos/services/backups.nix +++ b/nixos/services/backups.nix @@ -44,14 +44,14 @@ systemd.services.litestream = { after = [ "backup-secret.service" ]; requires = [ "backup-secret.service" ]; - environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + environment.AWS_ACCESS_KEY_ID = config.backup.s3.accessKeyId; }; # # Backup library to object storage # services.restic.backups.calibre = { # user = "calibre-web"; # repository = - # "s3://${config.backupS3.endpoint}/${config.backupS3.bucket}/calibre"; + # "s3://${config.backup.s3.endpoint}/${config.backup.s3.bucket}/calibre"; # paths = [ # "/var/books" # "/var/lib/calibre-web/app.db" @@ -59,7 +59,7 @@ # ]; # initialize = true; # timerConfig = { OnCalendar = "00:05:00"; }; - # environmentFile = backupS3File; + # environmentFile = backup.s3File; # }; }; diff --git a/nixos/services/calibre.nix b/nixos/services/calibre.nix index a3365e0..f12ec20 100644 --- a/nixos/services/calibre.nix +++ b/nixos/services/calibre.nix @@ -53,7 +53,7 @@ let libraryPath = "/var/lib/calibre-web"; # Default location in { description = "Backup Calibre data"; - environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + environment.AWS_ACCESS_KEY_ID = config.backup.s3.accessKeyId; serviceConfig = { Type = "oneshot"; User = "calibre-web"; @@ -63,8 +63,8 @@ script = '' ${pkgs.awscli2}/bin/aws s3 sync \ ${libraryPath}/ \ - s3://${config.backupS3.bucket}/calibre/ \ - --endpoint-url=https://${config.backupS3.endpoint} + s3://${config.backup.s3.bucket}/calibre/ \ + --endpoint-url=https://${config.backup.s3.endpoint} ''; }; diff --git a/nixos/services/gitea.nix b/nixos/services/gitea.nix index 4810279..e28429d 100644 --- a/nixos/services/gitea.nix +++ b/nixos/services/gitea.nix @@ -75,7 +75,7 @@ in { path = "${giteaPath}/data/gitea.db"; replicas = [{ url = - "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/gitea"; + "s3://${config.backup.s3.bucket}.${config.backup.s3.endpoint}/gitea"; }]; }]; }; diff --git a/nixos/services/n8n.nix b/nixos/services/n8n.nix index f06b1d6..e61096d 100644 --- a/nixos/services/n8n.nix +++ b/nixos/services/n8n.nix @@ -2,7 +2,7 @@ options = { n8nServer = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Hostname for n8n automation"; default = null; }; diff --git a/nixos/services/nextcloud.nix b/nixos/services/nextcloud.nix index fd1a01c..30093d5 100644 --- a/nixos/services/nextcloud.nix +++ b/nixos/services/nextcloud.nix @@ -69,7 +69,7 @@ path = "${config.services.nextcloud.datadir}/data/nextcloud.db"; replicas = [{ url = - "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/nextcloud"; + "s3://${config.backup.s3.bucket}.${config.backup.s3.endpoint}/nextcloud"; }]; }]; }; diff --git a/nixos/services/vaultwarden.nix b/nixos/services/vaultwarden.nix index c547dea..c02fa78 100644 --- a/nixos/services/vaultwarden.nix +++ b/nixos/services/vaultwarden.nix @@ -77,7 +77,7 @@ in { path = "${vaultwardenPath}/db.sqlite3"; replicas = [{ url = - "s3://${config.backupS3.bucket}.${config.backupS3.endpoint}/vaultwarden"; + "s3://${config.backup.s3.bucket}.${config.backup.s3.endpoint}/vaultwarden"; }]; }]; }; @@ -101,7 +101,7 @@ in { # Backup other Vaultwarden data to object storage systemd.services.vaultwarden-backup = { description = "Backup Vaultwarden files"; - environment.AWS_ACCESS_KEY_ID = config.backupS3.accessKeyId; + environment.AWS_ACCESS_KEY_ID = config.backup.s3.accessKeyId; serviceConfig = { Type = "oneshot"; User = "vaultwarden"; @@ -111,8 +111,8 @@ in { script = '' ${pkgs.awscli2}/bin/aws s3 sync \ ${vaultwardenPath}/ \ - s3://${config.backupS3.bucket}/vaultwarden/ \ - --endpoint-url=https://${config.backupS3.endpoint} \ + s3://${config.backup.s3.bucket}/vaultwarden/ \ + --endpoint-url=https://${config.backup.s3.endpoint} \ --exclude "*db.sqlite3*" \ --exclude ".db.sqlite3*" ''; From 524a5aa34773f407395695f5cc707b05515edcf6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 22 Dec 2022 00:47:25 +0000 Subject: [PATCH 164/391] enable missing configs for oracle --- hosts/oracle/default.nix | 4 ++++ nixos/hardware/default.nix | 1 + 2 files changed, 5 insertions(+) diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index 35df13a..e4a50db 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -23,6 +23,7 @@ nixpkgs.lib.nixosSystem { theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; wsl.enable = false; + caddy.enable = true; # FQDNs for various services networking.hostName = "oracle"; @@ -49,6 +50,7 @@ nixpkgs.lib.nixosSystem { users.users.nextcloud.extraGroups = [ "jellyfin" ]; # Wireguard config for Transmission + wireguard.enable = true; networking.wireguard.interfaces.wg0 = { # The local IPs for this machine within the Wireguard network @@ -88,6 +90,8 @@ nixpkgs.lib.nixosSystem { # Clone dotfiles dotfiles.enable = true; + neovim.enable = true; + } ]; } diff --git a/nixos/hardware/default.nix b/nixos/hardware/default.nix index 781e7f7..8dd57a5 100644 --- a/nixos/hardware/default.nix +++ b/nixos/hardware/default.nix @@ -7,6 +7,7 @@ ./monitors.nix ./mouse.nix ./networking.nix + ./server.nix ./sleep.nix ./wifi.nix ]; From 0bc8a233d8395f6f29eecbf0e69fe58274bc1650 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:48:53 -0700 Subject: [PATCH 165/391] enable missing neovim for macbook --- hosts/macbook/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index 0c23455..78620ed 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -27,6 +27,7 @@ darwin.lib.darwinSystem { nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; + neovim.enable = true; mail.enable = true; mail.aerc.enable = true; mail.himalaya.enable = true; From e4d76189e65d527239ff79f51e4eeb34d281aabe Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 6 Jan 2023 15:46:59 -0500 Subject: [PATCH 166/391] update lockfile --- flake.lock | 114 ++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/flake.lock b/flake.lock index 8bf9e60..13a1574 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "Comment-nvim-src": { "flake": false, "locked": { - "lastModified": 1668781964, - "narHash": "sha256-po1MyuuOH3e8yJTAtkxnusFSJuNpQnjpe+zfWPoO62E=", + "lastModified": 1672908537, + "narHash": "sha256-3UO8GPsyHi8qL9mGapNC7R4Yv03DKKQoUPJ0ORL0I6Y=", "owner": "numToStr", "repo": "Comment.nvim", - "rev": "5f01c1a89adafc52bf34e3bf690f80d9d726715d", + "rev": "ab00bcf5aa979c53f2f40dc2655c03e24f4ef50f", "type": "github" }, "original": { @@ -19,11 +19,11 @@ "bufferline-nvim-src": { "flake": false, "locked": { - "lastModified": 1668632062, - "narHash": "sha256-qGl1jwBaMFWsrth7F20KrfJpyVENF8GEOJsVBBcSTVA=", + "lastModified": 1671876022, + "narHash": "sha256-q8nwZRN97Sfrr7lHtNYwGdbS63obMOAxFFs/gSvqbqM=", "owner": "akinsho", "repo": "bufferline.nvim", - "rev": "4ecfa81e470a589e74adcde3d5bb1727dd407363", + "rev": "c7492a76ce8218e3335f027af44930576b561013", "type": "github" }, "original": { @@ -55,11 +55,11 @@ ] }, "locked": { - "lastModified": 1671196037, - "narHash": "sha256-2+J98SeczFWonbqFLMEAQC7vZEe6I2gM17XYvEmG52I=", + "lastModified": 1672753581, + "narHash": "sha256-EIi2tqHoje5cE9WqH23ZghW28NOOWSUM7tcxKE1U9KI=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "adb8ac0453c8b2c40f5bffb578453dbaee838952", + "rev": "3db1d870b04b13411f56ab1a50cd32b001f56433", "type": "github" }, "original": { @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1671410692, - "narHash": "sha256-azBs+c7zMnjNXntsnFM67AKsTdlUhU4eFzZwtTEGScs=", + "lastModified": 1672966280, + "narHash": "sha256-t6RsWdmLuy04rIecJkURuFNuwA81vDvsR3hJoX6FvZw=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "ce6bde60382284ca3044b4010143fec0c44a3cf5", + "rev": "f36ed6bbc104af39084838ff29fc0754b45f30e4", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1671459164, - "narHash": "sha256-RbkDnvLV7WjbiF4Dpiezrf8kXxwieQXAVtY8ciRQj6Q=", + "lastModified": 1672980560, + "narHash": "sha256-Pzx7az57SiUS1xhvKesTb1rhO9w9lWy9mecIqVjcKzo=", "owner": "nix-community", "repo": "home-manager", - "rev": "e7eba9cc46547ae86642ad3c6a9a4fb22c07bc26", + "rev": "1786883425208d3bf726ab6a1889beddeb46cdbc", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1670595719, - "narHash": "sha256-9jvA0QdcZtGWImiRZ8KRhXNsy5NxgZBm0TXtNLmFbyM=", + "lastModified": 1672668722, + "narHash": "sha256-i1MidLitMVa4k9UFbzdVoRyKy8y2NmYxVcVZdrdMEjw=", "owner": "oxalica", "repo": "nil", - "rev": "1c122ae707c6365ea731565daf307844df03e95e", + "rev": "0eff7fc333e3c0c064a6339834b44feae00fe64a", "type": "github" }, "original": { @@ -198,11 +198,11 @@ ] }, "locked": { - "lastModified": 1671522211, - "narHash": "sha256-i5BLrj3wlIC1VMQTfBSYIasEmv3D4as0Mu2K3rdJrSU=", + "lastModified": 1672738555, + "narHash": "sha256-owqLS8zro0IPjVta/gtdLTFX1Uluzp4uucLbQ4e1M2I=", "owner": "gytis-ivaskevicius", "repo": "nix2vim", - "rev": "3cc95ef557b6e2f97f5ff14ae89997a564d3a130", + "rev": "8d41475663f9e1209540d8c146c5a75ff4b3092a", "type": "github" }, "original": { @@ -234,11 +234,11 @@ ] }, "locked": { - "lastModified": 1671355134, - "narHash": "sha256-ZtnUWTDDyFog+NQBjZpnhgPdj3gHp5ImxFVWy+ObNno=", + "lastModified": 1672682641, + "narHash": "sha256-940TLvtdT8YKuP5nXcPhUfNeK0A/leSjjG8hfqvWM84=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "64a96ca8621d03cb3889daf0d3ff58d8209e3e0c", + "rev": "30516cb2b01896e14ce66893e414b6e3eec71cac", "type": "github" }, "original": { @@ -265,11 +265,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1670559856, - "narHash": "sha256-xUkgQRFqE6HIFQXs9SIXMZiXcLaH2415UR6w/FnsgcY=", + "lastModified": 1672338123, + "narHash": "sha256-CJ/t74PZYub7c0ezGLVfc0zg4xIkLipJCx+V1joxccI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6bc6f77cb171a74001033d94f17f49043a9f1804", + "rev": "1fc0a0f6c5290ce80b380d1eea3681a04aea1184", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1671359686, - "narHash": "sha256-3MpC6yZo+Xn9cPordGz2/ii6IJpP2n8LE8e/ebUXLrs=", + "lastModified": 1672791794, + "narHash": "sha256-mqGPpGmwap0Wfsf3o2b6qHJW1w2kk/I6cGCGIU+3t6o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "04f574a1c0fde90b51bf68198e2297ca4e7cccf4", + "rev": "9813adc7f7c0edd738c6bdd8431439688bb0cb3d", "type": "github" }, "original": { @@ -314,11 +314,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1671458255, - "narHash": "sha256-YQaWKSW9D1HEBva9GeivQkylFeYfTrFUiTkXYF4V8SA=", + "lastModified": 1672883683, + "narHash": "sha256-NArSS97ZqPqjVaXHRFkRUS3kE33oM5j5B/rA3oks600=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "db1c7cb5f6d6f6036b7f8433bb3cfcbe985cb3d1", + "rev": "6830a1ed04f89e6d556cb6bcc200433173004307", "type": "github" }, "original": { @@ -329,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1671547500, - "narHash": "sha256-97hzIBBNDbva9eRj1WomM+pimxt7hVrH/yNjUfJSMJc=", + "lastModified": 1673034383, + "narHash": "sha256-NvHObz16pNqFoUjBSPI0MoJ6HAhmWqfWl5JfyfkcIAc=", "owner": "nix-community", "repo": "nur", - "rev": "4103fbdf825891b4dc54a6bda72ef1757081444c", + "rev": "21b34d37ceea6d93bbfe4abd8ffaa0bf5290a2bf", "type": "github" }, "original": { @@ -345,11 +345,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1671517641, - "narHash": "sha256-RWXc/nCVNPv0BQN99QQMfeplQFpEsNJdmyoC/TQuIYQ=", + "lastModified": 1672821837, + "narHash": "sha256-ZlYRnFnH+dSZPS5qVRBSt+mdUTjxo3VUeu1L0eah5jc=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "d597b0f3605f43526f1b6948c6d7ca2919ea32ac", + "rev": "e69978a39e4d3262b09ce6a316beff384f443e3b", "type": "github" }, "original": { @@ -361,11 +361,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1671430707, - "narHash": "sha256-SdQ7nCgrtSN96XeaPjDoGnc++jllYy/up/jDc5LunRM=", + "lastModified": 1672712029, + "narHash": "sha256-/XYZrx7y4UcCeFE4sS2MhHvEptSEoPClZ0AQVYDr/ts=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "e14c2895b4f36a22001f7773244041c173dcf867", + "rev": "bac962caf472a4404ed3ce1ba2fcaf32f8002951", "type": "github" }, "original": { @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1671521720, - "narHash": "sha256-GeuRomX3cFXK/zqWf1SJ3WXbTSLLy3FT99lIyhVnefo=", + "lastModified": 1673030922, + "narHash": "sha256-aV7SMPZ82Z3TmoPKOqBY2RM505lCkrCHyfBqJrrVoGc=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "eedb7b9c69b13afe86461b0742266bb62b811ece", + "rev": "2d8e6b666297ddf19cbf7cbc2b0f1928bc49224a", "type": "github" }, "original": { @@ -426,11 +426,11 @@ ] }, "locked": { - "lastModified": 1670552927, - "narHash": "sha256-lCE51eAGrAFS4k9W5aDGFpVtOAwQQ/rFMN80PCDh0vo=", + "lastModified": 1672280602, + "narHash": "sha256-aBO2MgTv8Pj24j+q0BKFHV5XmAuAn6+iw7AVNW4wUxc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a0fdafd18c9cf599fde17fbaf07dbb20fa57eecb", + "rev": "ede977678e5d0164316998487e686d0790744cd7", "type": "github" }, "original": { @@ -442,11 +442,11 @@ "telescope-nvim-src": { "flake": false, "locked": { - "lastModified": 1669979094, - "narHash": "sha256-5UgCqnDs4iubnq7gER1wC8Mk9UZuo8cWqDB8ZbyGCRI=", + "lastModified": 1673030770, + "narHash": "sha256-9Y7HBalCd6hfPxpb0C06mU2JpJU11WufhC5PrsbKiTo=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "cabf991b1d3996fa6f3232327fc649bbdf676496", + "rev": "cd67e819e453643b818363e6b573484c8e2e41b0", "type": "github" }, "original": { @@ -458,11 +458,11 @@ "telescope-project-nvim-src": { "flake": false, "locked": { - "lastModified": 1665406281, - "narHash": "sha256-ZBFgUlW+h7vndazZ0lZux8i7yQHKJNDPQPZ2z96Rfpk=", + "lastModified": 1671805267, + "narHash": "sha256-S4SOHzQ17ux5pcwwYFpVVLzjLeC4/EJ0IFPbrfzUJC8=", "owner": "nvim-telescope", "repo": "telescope-project.nvim", - "rev": "ff4d3cea905383a67d1a47b9dd210c4907d858c2", + "rev": "8e8ee37b7210761502cdf2c3a82b5ba8fb5b2972", "type": "github" }, "original": { @@ -525,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1671480147, - "narHash": "sha256-IzWdZL8jMNtyKsXXJjn2L4MsBeR52WBdhciPw4latHU=", + "lastModified": 1672225470, + "narHash": "sha256-CL81URMZdjwCbqYY+WqIZAo1aj9moWNPISJaRw2YwV4=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "577d7919e4380e6905e69d4a5f8f48a41ca37187", + "rev": "79fa1eb78f746c30e41f1be76a209a407b25dc9d", "type": "github" }, "original": { From 2dda6a31bde28375006bb12512d61a5865ba1044 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 9 Jan 2023 13:09:12 -0500 Subject: [PATCH 167/391] update lockfile, fix treesitter for terraform filetypes --- flake.lock | 6 +++--- modules/neovim/config/lsp.nix | 5 ++++- modules/neovim/lua/settings.lua | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 13a1574..327e0dc 100644 --- a/flake.lock +++ b/flake.lock @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1673030922, - "narHash": "sha256-aV7SMPZ82Z3TmoPKOqBY2RM505lCkrCHyfBqJrrVoGc=", + "lastModified": 1673257831, + "narHash": "sha256-eIjdaPbWBYWAJ5konYwVtvwuSDgUdnbWG775nK/Vn7o=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "2d8e6b666297ddf19cbf7cbc2b0f1928bc49224a", + "rev": "d8c84521dc9f407f88dfca35b9572c6532207a4a", "type": "github" }, "original": { diff --git a/modules/neovim/config/lsp.nix b/modules/neovim/config/lsp.nix index 5a00369..39b8421 100644 --- a/modules/neovim/config/lsp.nix +++ b/modules/neovim/config/lsp.nix @@ -42,7 +42,10 @@ command = "${pkgs.shfmt}/bin/shfmt", extra_args = { "-i", "4", "-ci" }, }), - require("null-ls").builtins.formatting.terraform_fmt.with({ command = "${pkgs.terraform}/bin/terraform" }), + require("null-ls").builtins.formatting.terraform_fmt.with({ + command = "${pkgs.terraform}/bin/terraform", + extra_filetypes = { "hcl" }, + }), }, on_attach = function(client, bufnr) diff --git a/modules/neovim/lua/settings.lua b/modules/neovim/lua/settings.lua index a6896c9..81fdcfe 100644 --- a/modules/neovim/lua/settings.lua +++ b/modules/neovim/lua/settings.lua @@ -4,7 +4,8 @@ vim.filetype.add({ pattern = { - [".*%.tfvars"] = "terraform", + [".*%.tfvars"] = "hcl", + [".*%.tf"] = "hcl", }, }) From e7bbee5da05cc318f107254604308db59defd381 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 21 Jan 2023 09:29:03 -0500 Subject: [PATCH 168/391] fix desktop to work with refactor --- hosts/desktop/default.nix | 6 +++-- nixos/graphical/picom.nix | 1 - nixos/hardware/wifi.nix | 2 +- nixos/services/backups.nix | 8 +++---- nixos/services/calibre.nix | 2 +- nixos/services/gitea.nix | 2 +- nixos/services/jellyfin.nix | 2 +- nixos/services/nextcloud.nix | 2 +- nixos/services/prometheus.nix | 2 +- nixos/services/sshd.nix | 41 +++++++++++++++++----------------- nixos/services/vaultwarden.nix | 2 +- 11 files changed, 36 insertions(+), 34 deletions(-) diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 38f383f..9957ec3 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,4 +1,4 @@ -{ inputs, globals, ... }: +{ inputs, globals, overlays, ... }: with inputs; @@ -16,7 +16,7 @@ nixpkgs.lib.nixosSystem { { physical = true; networking.hostName = "desktop"; - nixpkgs.overlays = [ nur.overlay ]; + nixpkgs.overlays = [ nur.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; identityFile = "/home/${globals.user}/.ssh/id_ed25519"; @@ -29,7 +29,9 @@ nixpkgs.lib.nixosSystem { gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; wsl.enable = false; + publicKey = null; + neovim.enable = true; media.enable = true; firefox.enable = true; kitty.enable = true; diff --git a/nixos/graphical/picom.nix b/nixos/graphical/picom.nix index 819c8f3..102d4d5 100644 --- a/nixos/graphical/picom.nix +++ b/nixos/graphical/picom.nix @@ -24,7 +24,6 @@ # ''; }; fade = false; - experimentalBackends = true; inactiveOpacity = 1.0; menuOpacity = 1.0; opacityRules = [ diff --git a/nixos/hardware/wifi.nix b/nixos/hardware/wifi.nix index 10fd4f9..b6c5daa 100644 --- a/nixos/hardware/wifi.nix +++ b/nixos/hardware/wifi.nix @@ -1,6 +1,6 @@ { config, pkgs, lib, ... }: { - config = lib.mkIf (config.physical && config.isLinux) { + config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) { # Enables wireless support via wpa_supplicant. networking.wireless.enable = true; diff --git a/nixos/services/backups.nix b/nixos/services/backups.nix index 5c25048..c1e143b 100644 --- a/nixos/services/backups.nix +++ b/nixos/services/backups.nix @@ -4,17 +4,17 @@ backup.s3 = { endpoint = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "S3 endpoint for backups"; default = null; }; bucket = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "S3 bucket for backups"; default = null; }; accessKeyId = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "S3 access key ID for backups"; default = null; }; @@ -22,7 +22,7 @@ }; - config = { + config = lib.mkIf (config.backup.s3.endpoint != null) { users.groups.backup = { }; diff --git a/nixos/services/calibre.nix b/nixos/services/calibre.nix index f12ec20..1637244 100644 --- a/nixos/services/calibre.nix +++ b/nixos/services/calibre.nix @@ -2,7 +2,7 @@ options = { bookServer = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Hostname for Calibre library"; default = null; }; diff --git a/nixos/services/gitea.nix b/nixos/services/gitea.nix index e28429d..8c5281f 100644 --- a/nixos/services/gitea.nix +++ b/nixos/services/gitea.nix @@ -8,7 +8,7 @@ in { giteaServer = lib.mkOption { description = "Hostname for Gitea."; - type = lib.types.str; + type = lib.types.nullOr lib.types.str; default = null; }; diff --git a/nixos/services/jellyfin.nix b/nixos/services/jellyfin.nix index 4b8bb21..a870cdc 100644 --- a/nixos/services/jellyfin.nix +++ b/nixos/services/jellyfin.nix @@ -2,7 +2,7 @@ options = { streamServer = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Hostname for Jellyfin library"; default = null; }; diff --git a/nixos/services/nextcloud.nix b/nixos/services/nextcloud.nix index 30093d5..3e997c0 100644 --- a/nixos/services/nextcloud.nix +++ b/nixos/services/nextcloud.nix @@ -3,7 +3,7 @@ options = { nextcloudServer = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Hostname for Nextcloud"; default = null; }; diff --git a/nixos/services/prometheus.nix b/nixos/services/prometheus.nix index d8adb2f..b372cca 100644 --- a/nixos/services/prometheus.nix +++ b/nixos/services/prometheus.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: { options.metricsServer = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Hostname of the Grafana server."; default = null; }; diff --git a/nixos/services/sshd.nix b/nixos/services/sshd.nix index 9eb4265..229a21c 100644 --- a/nixos/services/sshd.nix +++ b/nixos/services/sshd.nix @@ -2,7 +2,7 @@ options = { publicKey = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Public SSH key authorized for this system."; }; permitRootLogin = lib.mkOption { @@ -12,25 +12,26 @@ }; }; - config = lib.mkIf (pkgs.stdenv.isLinux && !config.wsl.enable) { - services.openssh = { - enable = true; - ports = [ 22 ]; - passwordAuthentication = false; - gatewayPorts = "no"; - forwardX11 = false; - allowSFTP = true; - permitRootLogin = config.permitRootLogin; + config = lib.mkIf + (pkgs.stdenv.isLinux && !config.wsl.enable && config.publicKey != null) { + services.openssh = { + enable = true; + ports = [ 22 ]; + passwordAuthentication = false; + gatewayPorts = "no"; + forwardX11 = false; + allowSFTP = true; + permitRootLogin = config.permitRootLogin; + }; + + users.users.${config.user}.openssh.authorizedKeys.keys = + [ config.publicKey ]; + + # Implement a simple fail2ban service for sshd + services.sshguard.enable = true; + + # Add terminfo for SSH from popular terminal emulators + environment.enableAllTerminfo = true; }; - users.users.${config.user}.openssh.authorizedKeys.keys = - [ config.publicKey ]; - - # Implement a simple fail2ban service for sshd - services.sshguard.enable = true; - - # Add terminfo for SSH from popular terminal emulators - environment.enableAllTerminfo = true; - }; - } diff --git a/nixos/services/vaultwarden.nix b/nixos/services/vaultwarden.nix index c02fa78..c4cbf89 100644 --- a/nixos/services/vaultwarden.nix +++ b/nixos/services/vaultwarden.nix @@ -8,7 +8,7 @@ in { vaultwardenServer = lib.mkOption { description = "Hostname for Vaultwarden."; - type = lib.types.str; + type = lib.types.nullOr lib.types.str; default = null; }; From 7a4c3b930de2118936c3e91ee80d38c56b5b72ba Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 21 Jan 2023 10:44:39 -0500 Subject: [PATCH 169/391] firefox working again still polybar is broken --- flake.lock | 102 ++++++++++++++++++------------------ hosts/desktop/default.nix | 2 +- nixos/graphical/i3.nix | 6 +-- nixos/graphical/polybar.nix | 1 - 4 files changed, 53 insertions(+), 58 deletions(-) diff --git a/flake.lock b/flake.lock index 327e0dc..329b4be 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "Comment-nvim-src": { "flake": false, "locked": { - "lastModified": 1672908537, - "narHash": "sha256-3UO8GPsyHi8qL9mGapNC7R4Yv03DKKQoUPJ0ORL0I6Y=", + "lastModified": 1674040818, + "narHash": "sha256-7UtZAE9tPlnpeHS2LLol/LGVOxptDXNKWXHNHvFBNk4=", "owner": "numToStr", "repo": "Comment.nvim", - "rev": "ab00bcf5aa979c53f2f40dc2655c03e24f4ef50f", + "rev": "eab2c83a0207369900e92783f56990808082eac2", "type": "github" }, "original": { @@ -55,11 +55,11 @@ ] }, "locked": { - "lastModified": 1672753581, - "narHash": "sha256-EIi2tqHoje5cE9WqH23ZghW28NOOWSUM7tcxKE1U9KI=", + "lastModified": 1673295039, + "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "3db1d870b04b13411f56ab1a50cd32b001f56433", + "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", "type": "github" }, "original": { @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1672966280, - "narHash": "sha256-t6RsWdmLuy04rIecJkURuFNuwA81vDvsR3hJoX6FvZw=", + "lastModified": 1674175894, + "narHash": "sha256-qBwoX9JP+lw84JeJHGnjdQd7R2WW6WYDH0XZxOk9ruw=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "f36ed6bbc104af39084838ff29fc0754b45f30e4", + "rev": "e5d96f44143190f610b34096c65030d673d73df7", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1672980560, - "narHash": "sha256-Pzx7az57SiUS1xhvKesTb1rhO9w9lWy9mecIqVjcKzo=", + "lastModified": 1674250603, + "narHash": "sha256-SBolFspxBHpW3hCCDNAFXUiO2mucmkVmf17UmSIK3Cs=", "owner": "nix-community", "repo": "home-manager", - "rev": "1786883425208d3bf726ab6a1889beddeb46cdbc", + "rev": "275ab728912006eecb549338a50f24f294a7cfb7", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1672668722, - "narHash": "sha256-i1MidLitMVa4k9UFbzdVoRyKy8y2NmYxVcVZdrdMEjw=", + "lastModified": 1674113703, + "narHash": "sha256-au1KKVBZTyWulPxmy3CtNzJQrQWPZtTjwcfD/bDftgo=", "owner": "oxalica", "repo": "nil", - "rev": "0eff7fc333e3c0c064a6339834b44feae00fe64a", + "rev": "3f84b783d36d564c4380631ab48d771e2558cb81", "type": "github" }, "original": { @@ -198,11 +198,11 @@ ] }, "locked": { - "lastModified": 1672738555, - "narHash": "sha256-owqLS8zro0IPjVta/gtdLTFX1Uluzp4uucLbQ4e1M2I=", + "lastModified": 1673891598, + "narHash": "sha256-EevceKxQtA+I0XVA8tBGKmYV1V1KbWc3gsswysMzeDk=", "owner": "gytis-ivaskevicius", "repo": "nix2vim", - "rev": "8d41475663f9e1209540d8c146c5a75ff4b3092a", + "rev": "5b31eb81e2c6c74f9e8a4911660f3bf585d55158", "type": "github" }, "original": { @@ -265,11 +265,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1672338123, - "narHash": "sha256-CJ/t74PZYub7c0ezGLVfc0zg4xIkLipJCx+V1joxccI=", + "lastModified": 1673947312, + "narHash": "sha256-xx/2nRwRy3bXrtry6TtydKpJpqHahjuDB5sFkQ/XNDE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1fc0a0f6c5290ce80b380d1eea3681a04aea1184", + "rev": "2d38b664b4400335086a713a0036aafaa002c003", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1672791794, - "narHash": "sha256-mqGPpGmwap0Wfsf3o2b6qHJW1w2kk/I6cGCGIU+3t6o=", + "lastModified": 1674120619, + "narHash": "sha256-xLT1FQl7/jNPOEq5q/vmc3AExt1V9LtcjM+QY2+MUpA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9813adc7f7c0edd738c6bdd8431439688bb0cb3d", + "rev": "d7705c01ef0a39c8ef532d1033bace8845a07d35", "type": "github" }, "original": { @@ -314,11 +314,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1672883683, - "narHash": "sha256-NArSS97ZqPqjVaXHRFkRUS3kE33oM5j5B/rA3oks600=", + "lastModified": 1674229858, + "narHash": "sha256-AzdjMymqIr/wE4Rt/N+vpqIDDgmJlC3LamhuOwYqytI=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "6830a1ed04f89e6d556cb6bcc200433173004307", + "rev": "33cfeb7a761f08e8535dca722d4b237cabadd371", "type": "github" }, "original": { @@ -329,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1673034383, - "narHash": "sha256-NvHObz16pNqFoUjBSPI0MoJ6HAhmWqfWl5JfyfkcIAc=", + "lastModified": 1674308735, + "narHash": "sha256-9biyeQ439FR4FYCHlKych5by7UrwU/Qr/63R13L9M/4=", "owner": "nix-community", "repo": "nur", - "rev": "21b34d37ceea6d93bbfe4abd8ffaa0bf5290a2bf", + "rev": "ca66f7c9b8c233305f7635dd9c9f73f0e3c4e9fe", "type": "github" }, "original": { @@ -345,11 +345,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1672821837, - "narHash": "sha256-ZlYRnFnH+dSZPS5qVRBSt+mdUTjxo3VUeu1L0eah5jc=", + "lastModified": 1674280543, + "narHash": "sha256-cvY8a+RAcBekZtGwBeGix0p2A6DdeGzL+86L6Lwd8hU=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "e69978a39e4d3262b09ce6a316beff384f443e3b", + "rev": "7b92695d1c444cdd5cd72c86922762a5dbc920fb", "type": "github" }, "original": { @@ -361,11 +361,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1672712029, - "narHash": "sha256-/XYZrx7y4UcCeFE4sS2MhHvEptSEoPClZ0AQVYDr/ts=", + "lastModified": 1674274878, + "narHash": "sha256-lrU2p0qqCKS9aaf30OwBX741ouAR878mr2Lgbtbn74w=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "bac962caf472a4404ed3ce1ba2fcaf32f8002951", + "rev": "96506fee49542f3aedab76368d400a147fea344e", "type": "github" }, "original": { @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1673257831, - "narHash": "sha256-eIjdaPbWBYWAJ5konYwVtvwuSDgUdnbWG775nK/Vn7o=", + "lastModified": 1674304755, + "narHash": "sha256-2TzkenDgQosl5xHWLD+TWT1D/NaIzyeUniRhBhLCZsk=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "d8c84521dc9f407f88dfca35b9572c6532207a4a", + "rev": "08e1adae538083cf541c201a49fe7602bf308d65", "type": "github" }, "original": { @@ -426,11 +426,11 @@ ] }, "locked": { - "lastModified": 1672280602, - "narHash": "sha256-aBO2MgTv8Pj24j+q0BKFHV5XmAuAn6+iw7AVNW4wUxc=", + "lastModified": 1674095406, + "narHash": "sha256-RexH/1rZTiX4OhdYkuJP3MuANJ+JRgoLKL60iHm//T0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "ede977678e5d0164316998487e686d0790744cd7", + "rev": "5f7315b9800e2e500e6834767a57e39f7dbfd495", "type": "github" }, "original": { @@ -442,11 +442,11 @@ "telescope-nvim-src": { "flake": false, "locked": { - "lastModified": 1673030770, - "narHash": "sha256-9Y7HBalCd6hfPxpb0C06mU2JpJU11WufhC5PrsbKiTo=", + "lastModified": 1673904050, + "narHash": "sha256-f0KNw5lER1xchDBOITUx1FyX/Da5KUWyR0uVtPn/1Zg=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "cd67e819e453643b818363e6b573484c8e2e41b0", + "rev": "2f32775405f6706348b71d0bb8a15a22852a61e4", "type": "github" }, "original": { @@ -474,11 +474,11 @@ "toggleterm-nvim-src": { "flake": false, "locked": { - "lastModified": 1670593071, - "narHash": "sha256-0n3WbUM3rYyR2BXgeyYuyTZIbIs5dzuIu8imsSvAc8U=", + "lastModified": 1673603637, + "narHash": "sha256-qsEtCDEy/EsMChZ9Ysv0Z5knKp4sISb2BnSrfWsECR8=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "b02a1674bd0010d7982b056fd3df4f717ff8a57a", + "rev": "a54e6c471ce1cd8ef8357e34598a28a955297131", "type": "github" }, "original": { @@ -525,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1672225470, - "narHash": "sha256-CL81URMZdjwCbqYY+WqIZAo1aj9moWNPISJaRw2YwV4=", + "lastModified": 1674151125, + "narHash": "sha256-7kkdtTKfvoAzGV8F7gCr1WX6FMadF6s8a1QUaMHOSzA=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "79fa1eb78f746c30e41f1be76a209a407b25dc9d", + "rev": "13f5b22fb03ed3c22522c9e7d5e3403fb318070e", "type": "github" }, "original": { diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 9957ec3..4e4f4e6 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -46,7 +46,7 @@ nixpkgs.lib.nixosSystem { gaming.steam.enable = true; gaming.legendary.enable = true; keybase.enable = true; - mullvad.enable = true; + # mullvad.enable = true; nixlang.enable = true; dotfiles.enable = true; } diff --git a/nixos/graphical/i3.nix b/nixos/graphical/i3.nix index dfaaed4..d41e3be 100644 --- a/nixos/graphical/i3.nix +++ b/nixos/graphical/i3.nix @@ -12,10 +12,7 @@ in { config = lib.mkIf pkgs.stdenv.isLinux { services.xserver.windowManager = { - i3 = { - enable = config.services.xserver.enable; - package = pkgs.i3-gaps; - }; + i3 = { enable = config.services.xserver.enable; }; }; environment.systemPackages = with pkgs; [ @@ -26,7 +23,6 @@ in { home-manager.users.${config.user} = { xsession.windowManager.i3 = { enable = config.services.xserver.enable; - package = pkgs.i3-gaps; config = let modifier = "Mod4"; # Super key ws1 = "1:I"; diff --git a/nixos/graphical/polybar.nix b/nixos/graphical/polybar.nix index d8457a9..99eb813 100644 --- a/nixos/graphical/polybar.nix +++ b/nixos/graphical/polybar.nix @@ -9,7 +9,6 @@ services.polybar = { enable = true; package = pkgs.polybar.override { - i3GapsSupport = true; pulseSupport = true; githubSupport = true; }; From 17799909b2d518167354dc5cede3b15cced2b180 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 21 Jan 2023 19:46:56 -0500 Subject: [PATCH 170/391] fix: polybar not showing i3 workspaces --- nixos/graphical/polybar.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/graphical/polybar.nix b/nixos/graphical/polybar.nix index 99eb813..2befe82 100644 --- a/nixos/graphical/polybar.nix +++ b/nixos/graphical/polybar.nix @@ -11,6 +11,7 @@ package = pkgs.polybar.override { pulseSupport = true; githubSupport = true; + i3Support = true; }; script = "polybar &"; config = { From 8915f17ea31574e08be03e260903d74e17f36bce Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 28 Jan 2023 15:36:52 +0000 Subject: [PATCH 171/391] fixes for latest wsl --- hosts/wsl/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix index e076c60..ef448c4 100644 --- a/hosts/wsl/default.nix +++ b/hosts/wsl/default.nix @@ -1,4 +1,4 @@ -{ inputs, globals, ... }: +{ inputs, globals, overlays, ... }: with inputs; @@ -14,6 +14,7 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager { networking.hostName = "wsl"; + nixpkgs.overlays = overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; identityFile = "/home/${globals.user}/.ssh/id_ed25519"; @@ -25,7 +26,7 @@ nixpkgs.lib.nixosSystem { passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; wsl = { enable = true; - automountPath = "/mnt"; + wslConf.automount.root = "/mnt"; defaultUser = globals.user; startMenuLaunchers = true; wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN @@ -33,6 +34,7 @@ nixpkgs.lib.nixosSystem { false; # Including Windows PATH will slow down Neovim command mode }; + neovim.enable = true; mail.enable = true; mail.aerc.enable = true; mail.himalaya.enable = true; From 521937e36609d74b33be99e3b89d49165ea3a2ac Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 31 Jan 2023 09:07:47 -0500 Subject: [PATCH 172/391] fix desktop for new pc build --- hosts/desktop/hardware-configuration.nix | 36 +++++++++++++++--------- nixos/hardware/monitors.nix | 4 +-- nixos/hardware/networking.nix | 4 +-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index af59134..e4e7a0b 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -4,27 +4,35 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = - [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; + boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - }; + fileSystems."/" = + { device = "/dev/disk/by-uuid/f0313f58-971a-46e3-9191-909fe5eb7f7e"; + fsType = "ext4"; + }; - fileSystems."/boot" = { - device = "/dev/disk/by-label/boot"; - fsType = "vfat"; - }; + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FB26-799C"; + fsType = "vfat"; + }; swapDevices = [ ]; + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp5s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - hardware.cpu.intel.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/nixos/hardware/monitors.nix b/nixos/hardware/monitors.nix index e8cf5b9..e07e448 100644 --- a/nixos/hardware/monitors.nix +++ b/nixos/hardware/monitors.nix @@ -32,11 +32,11 @@ # Set up screen position and rotation setupCommands = '' - ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ + ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-1 \ --mode 1920x1200 \ --pos 1920x0 \ --rotate left \ - --output HDMI-0 \ + --output HDMI-A-0 \ --primary \ --mode 1920x1080 \ --pos 0x560 \ diff --git a/nixos/hardware/networking.nix b/nixos/hardware/networking.nix index a9017bd..f157de9 100644 --- a/nixos/hardware/networking.nix +++ b/nixos/hardware/networking.nix @@ -6,8 +6,8 @@ # Per-interface useDHCP will be mandatory in the future, so this generated config # replicates the default behaviour. networking.useDHCP = false; - networking.interfaces.enp0s31f6.useDHCP = true; - networking.interfaces.wlp3s0.useDHCP = true; + networking.interfaces.enp5s0.useDHCP = true; + networking.interfaces.wlp4s0.useDHCP = true; }; From ceaad9d186990b74255026609dd726d8286e37c0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 2 Feb 2023 11:01:12 -0500 Subject: [PATCH 173/391] update lockfile, fix age not building --- flake.lock | 84 ++++++++++++++++---------------- modules/applications/firefox.nix | 2 +- modules/shell/utilities.nix | 14 ++++++ 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/flake.lock b/flake.lock index 329b4be..e419498 100644 --- a/flake.lock +++ b/flake.lock @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1674175894, - "narHash": "sha256-qBwoX9JP+lw84JeJHGnjdQd7R2WW6WYDH0XZxOk9ruw=", + "lastModified": 1675299131, + "narHash": "sha256-tMQKjyKTe4H4X5UsRpwbjKuKoOUkPFpjn9DqvB6/ijA=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "e5d96f44143190f610b34096c65030d673d73df7", + "rev": "c4ed0e71e6ecb44b1237aa6acb70aaa0b6e924fa", "type": "github" }, "original": { @@ -90,11 +90,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1674250603, - "narHash": "sha256-SBolFspxBHpW3hCCDNAFXUiO2mucmkVmf17UmSIK3Cs=", + "lastModified": 1675303228, + "narHash": "sha256-dHJbFg7gTuTyEUdJoNDp6l2bac6HXAT/bz9cVEqL+Uw=", "owner": "nix-community", "repo": "home-manager", - "rev": "275ab728912006eecb549338a50f24f294a7cfb7", + "rev": "4a958524903e6019f5f69a23e0c0f16e5af01eb0", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1674113703, - "narHash": "sha256-au1KKVBZTyWulPxmy3CtNzJQrQWPZtTjwcfD/bDftgo=", + "lastModified": 1674921146, + "narHash": "sha256-PsDZsQ3EJUW5i4qiNZ3z5H+N+oQaKOqC7xNkd+aUqQw=", "owner": "oxalica", "repo": "nil", - "rev": "3f84b783d36d564c4380631ab48d771e2558cb81", + "rev": "dfd91e3b7e760559bd79226ad5ad41444078a882", "type": "github" }, "original": { @@ -234,11 +234,11 @@ ] }, "locked": { - "lastModified": 1672682641, - "narHash": "sha256-940TLvtdT8YKuP5nXcPhUfNeK0A/leSjjG8hfqvWM84=", + "lastModified": 1674666581, + "narHash": "sha256-KNI2s/xrL7WOYaPJAWKBtb7cCH3335rLfsL+B+ssuGY=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "30516cb2b01896e14ce66893e414b6e3eec71cac", + "rev": "6a5dc1d3d557ea7b5c19b15ff91955124d0400fa", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1674120619, - "narHash": "sha256-xLT1FQl7/jNPOEq5q/vmc3AExt1V9LtcjM+QY2+MUpA=", + "lastModified": 1675183161, + "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d7705c01ef0a39c8ef532d1033bace8845a07d35", + "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", "type": "github" }, "original": { @@ -297,11 +297,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1671313200, - "narHash": "sha256-itZTrtHeDJjV696+ur0/TzkTqb5y3Eb57WRLRPK3rwA=", + "lastModified": 1674868155, + "narHash": "sha256-eFNm2h6fNbgD7ZpO4MHikCB5pSnCJ7DTmwPisjetmwc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0938d73bb143f4ae037143572f11f4338c7b2d1c", + "rev": "ce20e9ebe1903ea2ba1ab006ec63093020c761cb", "type": "github" }, "original": { @@ -314,11 +314,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1674229858, - "narHash": "sha256-AzdjMymqIr/wE4Rt/N+vpqIDDgmJlC3LamhuOwYqytI=", + "lastModified": 1675186656, + "narHash": "sha256-pucn9YCeQaOVXCrH+C42C8hkfMsYcxRkdjQbb223qhA=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "33cfeb7a761f08e8535dca722d4b237cabadd371", + "rev": "c3e678110d5f31854c6575cf4bda3b82f3d4a884", "type": "github" }, "original": { @@ -329,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1674308735, - "narHash": "sha256-9biyeQ439FR4FYCHlKych5by7UrwU/Qr/63R13L9M/4=", + "lastModified": 1675325243, + "narHash": "sha256-KdvpDpvM1SnXQAmjtA/PWjIEaOl5MU9nRuO66W9JP44=", "owner": "nix-community", "repo": "nur", - "rev": "ca66f7c9b8c233305f7635dd9c9f73f0e3c4e9fe", + "rev": "d2540a896eba1945c76d90b9b95648036efb6134", "type": "github" }, "original": { @@ -345,11 +345,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1674280543, - "narHash": "sha256-cvY8a+RAcBekZtGwBeGix0p2A6DdeGzL+86L6Lwd8hU=", + "lastModified": 1675162896, + "narHash": "sha256-2XmfhBldseP9zxrQBFtapUpMBIkhKgyiM+xUbP+os8I=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "7b92695d1c444cdd5cd72c86922762a5dbc920fb", + "rev": "902d6aa31450d26e11bedcbef8af5b6fe2e1ffe8", "type": "github" }, "original": { @@ -361,11 +361,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1674274878, - "narHash": "sha256-lrU2p0qqCKS9aaf30OwBX741ouAR878mr2Lgbtbn74w=", + "lastModified": 1675128430, + "narHash": "sha256-gs50ubONKCxxXfR6wu6238s71R5Gmaot3unxpMFZOwM=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "96506fee49542f3aedab76368d400a147fea344e", + "rev": "215b29bfad74518442621b9d0483a621483b066b", "type": "github" }, "original": { @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1674304755, - "narHash": "sha256-2TzkenDgQosl5xHWLD+TWT1D/NaIzyeUniRhBhLCZsk=", + "lastModified": 1675341636, + "narHash": "sha256-wgMcA1fdjkGW04lj9JTixDoTIeJVn1nVb1LreOiSoR8=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "08e1adae538083cf541c201a49fe7602bf308d65", + "rev": "69867ffe7e05559fdb055f6b5a2589fc6bee1070", "type": "github" }, "original": { @@ -442,11 +442,11 @@ "telescope-nvim-src": { "flake": false, "locked": { - "lastModified": 1673904050, - "narHash": "sha256-f0KNw5lER1xchDBOITUx1FyX/Da5KUWyR0uVtPn/1Zg=", + "lastModified": 1675149856, + "narHash": "sha256-L4Kw94CUy6N7zcyy9INuR/O0fxQ7sp0IvGd/u7fHxMA=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "2f32775405f6706348b71d0bb8a15a22852a61e4", + "rev": "203bf5609137600d73e8ed82703d6b0e320a5f36", "type": "github" }, "original": { @@ -525,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1674151125, - "narHash": "sha256-7kkdtTKfvoAzGV8F7gCr1WX6FMadF6s8a1QUaMHOSzA=", + "lastModified": 1675340793, + "narHash": "sha256-+FuLbM5gpRHt1ZSOrJhMjHSm7hhvYZIaBnL2mw6rF50=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "13f5b22fb03ed3c22522c9e7d5e3403fb318070e", + "rev": "e110ed426e1823b32a2409227560af88348f7e24", "type": "github" }, "original": { diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 537181d..0e65d67 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -54,7 +54,7 @@ "browser.quitShortcut.disabled" = if pkgs.stdenv.isLinux then true else false; "browser.theme.dark-private-windows" = true; - "browser.toolbars.bookmarks.visibility" = "newtab"; + "browser.toolbars.bookmarks.visibility" = false; "browser.startup.page" = 3; # Restore previous session "browser.newtabpage.enabled" = false; # Make new tabs blank "trailhead.firstrun.didSeeAboutWelcome" = diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index 30d6741..53a59ef 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -17,6 +17,20 @@ in { home-manager.users.${config.user} = { + # Fix: age won't build + nixpkgs.overlays = [ + (final: prev: { + age = prev.age.overrideAttrs (old: { + src = prev.fetchFromGitHub { + owner = "FiloSottile"; + repo = "age"; + rev = "7354aa0d08a06eac42c635670a55f858bd23c943"; + sha256 = "H80mNTgZmExDMgubONIXP7jmLBvNMVqXee6NiZJhPFY="; + }; + }); + }) + ]; + home.packages = with pkgs; [ unzip # Extract zips rsync # Copy folders From a9a06fb5fc534506f761f3f857a3df9aa988747e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Feb 2023 17:16:20 -0500 Subject: [PATCH 174/391] fix steam games not launching --- flake.lock | 48 ++++++++++++------------ hosts/desktop/default.nix | 12 ++++-- hosts/desktop/hardware-configuration.nix | 30 ++++++++------- nixos/gaming/default.nix | 1 + 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/flake.lock b/flake.lock index e419498..be3a36c 100644 --- a/flake.lock +++ b/flake.lock @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1675303228, - "narHash": "sha256-dHJbFg7gTuTyEUdJoNDp6l2bac6HXAT/bz9cVEqL+Uw=", + "lastModified": 1675371293, + "narHash": "sha256-LrCjtrAXj/WJphhGEMnHgZs7oTsfOlvPfOjFTIvg39k=", "owner": "nix-community", "repo": "home-manager", - "rev": "4a958524903e6019f5f69a23e0c0f16e5af01eb0", + "rev": "d1c7730bb707bf8124d997952f7babd2a281ae68", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1674921146, - "narHash": "sha256-PsDZsQ3EJUW5i4qiNZ3z5H+N+oQaKOqC7xNkd+aUqQw=", + "lastModified": 1675427255, + "narHash": "sha256-d53add4Cuh0ik8YYncdoqqR6irQbnh/X4vg12TQ/FEQ=", "owner": "oxalica", "repo": "nil", - "rev": "dfd91e3b7e760559bd79226ad5ad41444078a882", + "rev": "3de72eefd8114b30f8ea82ead846a9401c262475", "type": "github" }, "original": { @@ -265,11 +265,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1673947312, - "narHash": "sha256-xx/2nRwRy3bXrtry6TtydKpJpqHahjuDB5sFkQ/XNDE=", + "lastModified": 1675309347, + "narHash": "sha256-D3CQ6HRDT2m3XJlrzb5jKq4vNFR5xFTEFKC7iSjlFpM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2d38b664b4400335086a713a0036aafaa002c003", + "rev": "006c3bd4dd2f5d1d2094047f307cbf9e2b73d9c5", "type": "github" }, "original": { @@ -329,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1675325243, - "narHash": "sha256-KdvpDpvM1SnXQAmjtA/PWjIEaOl5MU9nRuO66W9JP44=", + "lastModified": 1675390386, + "narHash": "sha256-VK1EGF9+U2A72Gy5lgHHa6DaGOnx3Ml51E0TewYh5L8=", "owner": "nix-community", "repo": "nur", - "rev": "d2540a896eba1945c76d90b9b95648036efb6134", + "rev": "f9a67871a7c1dcd424a20b6e3723eacc0704bc97", "type": "github" }, "original": { @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1675341636, - "narHash": "sha256-wgMcA1fdjkGW04lj9JTixDoTIeJVn1nVb1LreOiSoR8=", + "lastModified": 1675373326, + "narHash": "sha256-uC5AMeoWvjxf4b7Mysnsze/SRTawRjS9pBddMveUNYI=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "69867ffe7e05559fdb055f6b5a2589fc6bee1070", + "rev": "660a070af7131387c690c7b839718371916e27f9", "type": "github" }, "original": { @@ -426,11 +426,11 @@ ] }, "locked": { - "lastModified": 1674095406, - "narHash": "sha256-RexH/1rZTiX4OhdYkuJP3MuANJ+JRgoLKL60iHm//T0=", + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "5f7315b9800e2e500e6834767a57e39f7dbfd495", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", "type": "github" }, "original": { @@ -474,11 +474,11 @@ "toggleterm-nvim-src": { "flake": false, "locked": { - "lastModified": 1673603637, - "narHash": "sha256-qsEtCDEy/EsMChZ9Ysv0Z5knKp4sISb2BnSrfWsECR8=", + "lastModified": 1675358836, + "narHash": "sha256-9O7p/7tRStg51OFhMc88M5ewYquiYC9x9CV4s5veVP8=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "a54e6c471ce1cd8ef8357e34598a28a955297131", + "rev": "19aad0f41f47affbba1274f05e3c067e6d718e1e", "type": "github" }, "original": { @@ -525,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1675340793, - "narHash": "sha256-+FuLbM5gpRHt1ZSOrJhMjHSm7hhvYZIaBnL2mw6rF50=", + "lastModified": 1675351082, + "narHash": "sha256-4Oi4k4Qp1vOvKoACHDcz0xiVj7DuMaCL57fP3W77eA0=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "e110ed426e1823b32a2409227560af88348f7e24", + "rev": "52cadf92e1bfdef235d5cd77b9a4b2ab848baa8a", "type": "github" }, "original": { diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 4e4f4e6..0bbf3aa 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -42,13 +42,19 @@ nixpkgs.lib.nixosSystem { mail.enable = true; mail.aerc.enable = true; mail.himalaya.enable = true; - gaming.enable = true; - gaming.steam.enable = true; - gaming.legendary.enable = true; keybase.enable = true; # mullvad.enable = true; nixlang.enable = true; dotfiles.enable = true; + + gaming = { + enable = true; + steam.enable = true; + legendary.enable = true; + lutris.enable = true; + leagueoflegends.enable = true; + }; + } ]; } diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index e4e7a0b..82abb50 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -4,24 +4,25 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; + boot.initrd.availableKernelModules = + [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "amdgpu" ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/f0313f58-971a-46e3-9191-909fe5eb7f7e"; - fsType = "ext4"; - }; + services.xserver.videoDrivers = [ "amdgpu" ]; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/FB26-799C"; - fsType = "vfat"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/f0313f58-971a-46e3-9191-909fe5eb7f7e"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/FB26-799C"; + fsType = "vfat"; + }; swapDevices = [ ]; @@ -34,5 +35,6 @@ # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.amd.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/nixos/gaming/default.nix b/nixos/gaming/default.nix index 1b459de..c1fe519 100644 --- a/nixos/gaming/default.nix +++ b/nixos/gaming/default.nix @@ -13,6 +13,7 @@ config = lib.mkIf (config.gaming.enable && pkgs.stdenv.isLinux) { hardware.opengl = { enable = true; + driSupport = true; driSupport32Bit = true; }; }; From fa69557cedc06d35961182db714040eee7f34741 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:35:38 +0000 Subject: [PATCH 175/391] change hostname theme --- flake.nix | 19 ++++++++++--------- hosts/{oracle => flame}/default.nix | 11 ++++++----- .../hardware-configuration.nix | 0 hosts/{wsl => hydra}/default.nix | 7 +++++-- hosts/{macbook => lookingglass}/default.nix | 4 +++- hosts/{desktop => tempest}/default.nix | 6 ++++-- .../hardware-configuration.nix | 0 7 files changed, 28 insertions(+), 19 deletions(-) rename hosts/{oracle => flame}/default.nix (98%) rename hosts/{oracle => flame}/hardware-configuration.nix (100%) rename hosts/{wsl => hydra}/default.nix (94%) rename hosts/{macbook => lookingglass}/default.nix (95%) rename hosts/{desktop => tempest}/default.nix (96%) rename hosts/{desktop => tempest}/hardware-configuration.nix (100%) diff --git a/flake.nix b/flake.nix index 8eff23d..6086814 100644 --- a/flake.nix +++ b/flake.nix @@ -125,22 +125,23 @@ in rec { nixosConfigurations = { - desktop = import ./hosts/desktop { inherit inputs globals overlays; }; - wsl = import ./hosts/wsl { inherit inputs globals overlays; }; - oracle = import ./hosts/oracle { inherit inputs globals overlays; }; + tempest = import ./hosts/tempest { inherit inputs globals overlays; }; + hydra = import ./hosts/hydra { inherit inputs globals overlays; }; + flame = import ./hosts/flame { inherit inputs globals overlays; }; }; darwinConfigurations = { - macbook = import ./hosts/macbook { inherit inputs globals overlays; }; + lookingglass = + import ./hosts/macbook { inherit inputs globals overlays; }; }; # For quickly applying local settings with: - # home-manager switch --flake .#desktop + # home-manager switch --flake .#tempest homeConfigurations = { - desktop = - nixosConfigurations.desktop.config.home-manager.users.${globals.user}.home; - macbook = - darwinConfigurations.macbook.config.home-manager.users."Noah.Masur".home; + tempest = + nixosConfigurations.tempest.config.home-manager.users.${globals.user}.home; + lookingglass = + darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; # Package servers into images with a generator diff --git a/hosts/oracle/default.nix b/hosts/flame/default.nix similarity index 98% rename from hosts/oracle/default.nix rename to hosts/flame/default.nix index e4a50db..857f8e8 100644 --- a/hosts/oracle/default.nix +++ b/hosts/flame/default.nix @@ -1,12 +1,13 @@ -{ inputs, globals, overlays, ... }: - -with inputs; - +# The Flame # System configuration for an Oracle free server # How to install: # https://blog.korfuri.fr/posts/2022/08/nixos-on-an-oracle-free-tier-ampere-machine/ +{ inputs, globals, overlays, ... }: + +with inputs; + nixpkgs.lib.nixosSystem { system = "aarch64-linux"; specialArgs = { }; @@ -26,7 +27,7 @@ nixpkgs.lib.nixosSystem { caddy.enable = true; # FQDNs for various services - networking.hostName = "oracle"; + networking.hostName = "flame"; bookServer = "books.masu.rs"; streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; diff --git a/hosts/oracle/hardware-configuration.nix b/hosts/flame/hardware-configuration.nix similarity index 100% rename from hosts/oracle/hardware-configuration.nix rename to hosts/flame/hardware-configuration.nix diff --git a/hosts/wsl/default.nix b/hosts/hydra/default.nix similarity index 94% rename from hosts/wsl/default.nix rename to hosts/hydra/default.nix index ef448c4..63e3273 100644 --- a/hosts/wsl/default.nix +++ b/hosts/hydra/default.nix @@ -1,8 +1,10 @@ +# The Hydra +# System configuration for WSL + { inputs, globals, overlays, ... }: with inputs; -# System configuration for WSL nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { }; @@ -13,7 +15,7 @@ nixpkgs.lib.nixosSystem { wsl.nixosModules.wsl home-manager.nixosModules.home-manager { - networking.hostName = "wsl"; + networking.hostName = "hydra"; nixpkgs.overlays = overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; @@ -29,6 +31,7 @@ nixpkgs.lib.nixosSystem { wslConf.automount.root = "/mnt"; defaultUser = globals.user; startMenuLaunchers = true; + nativeSystemd = true; wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN interop.includePath = false; # Including Windows PATH will slow down Neovim command mode diff --git a/hosts/macbook/default.nix b/hosts/lookingglass/default.nix similarity index 95% rename from hosts/macbook/default.nix rename to hosts/lookingglass/default.nix index 78620ed..3eb9573 100644 --- a/hosts/macbook/default.nix +++ b/hosts/lookingglass/default.nix @@ -1,8 +1,10 @@ +# The Looking Glass +# System configuration for my work Macbook + { inputs, globals, overlays, ... }: with inputs; -# System configuration for my work MacBook darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs = { }; diff --git a/hosts/desktop/default.nix b/hosts/tempest/default.nix similarity index 96% rename from hosts/desktop/default.nix rename to hosts/tempest/default.nix index 0bbf3aa..73e8216 100644 --- a/hosts/desktop/default.nix +++ b/hosts/tempest/default.nix @@ -1,8 +1,10 @@ +# The Tempest +# System configuration for my desktop + { inputs, globals, overlays, ... }: with inputs; -# System configuration for my desktop nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { }; @@ -15,7 +17,7 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager { physical = true; - networking.hostName = "desktop"; + networking.hostName = "tempest"; nixpkgs.overlays = [ nur.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/tempest/hardware-configuration.nix similarity index 100% rename from hosts/desktop/hardware-configuration.nix rename to hosts/tempest/hardware-configuration.nix From 37fa835c662e31e8573b8f9390b0023581d0934d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Feb 2023 21:26:12 -0500 Subject: [PATCH 176/391] update lockfile, host name updates --- apps/default.nix | 2 +- darwin/nixpkgs.nix | 4 +- flake.lock | 72 ++++++++++++++++---------------- flake.nix | 2 +- modules/applications/firefox.nix | 38 ++++++++--------- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/apps/default.nix b/apps/default.nix index aa13880..f4e9064 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -34,7 +34,7 @@ echo ${pkgs.system} SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"} if [ "$SYSTEM" == "darwin" ]; then - darwin-rebuild switch --flake github:nmasur/dotfiles#macbook + darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass else nixos-rebuild switch --flake github:nmasur/dotfiles fi diff --git a/darwin/nixpkgs.nix b/darwin/nixpkgs.nix index d1b4778..adbbd3d 100644 --- a/darwin/nixpkgs.nix +++ b/darwin/nixpkgs.nix @@ -14,14 +14,14 @@ set option "--option substitute false" end git -C ${config.dotfilesPath} add --intent-to-add --all - commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#macbook" + commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#lookingglass" commandline --function execute ''; }; rebuild-home = lib.mkForce { body = '' git -C ${config.dotfilesPath} add --intent-to-add --all - commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#macbook"; + commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#lookingglass"; commandline --function execute ''; }; diff --git a/flake.lock b/flake.lock index be3a36c..2fca296 100644 --- a/flake.lock +++ b/flake.lock @@ -19,11 +19,11 @@ "bufferline-nvim-src": { "flake": false, "locked": { - "lastModified": 1671876022, - "narHash": "sha256-q8nwZRN97Sfrr7lHtNYwGdbS63obMOAxFFs/gSvqbqM=", + "lastModified": 1676130961, + "narHash": "sha256-3LT45i0eSMfUV9EBrtdtzHxFKRATIhRy/faDd3lI3mA=", "owner": "akinsho", "repo": "bufferline.nvim", - "rev": "c7492a76ce8218e3335f027af44930576b561013", + "rev": "84b0822b2af478d0b4f7b0f9249ca218855331db", "type": "github" }, "original": { @@ -35,11 +35,11 @@ "cmp-nvim-lsp-src": { "flake": false, "locked": { - "lastModified": 1668566979, - "narHash": "sha256-Mqkp8IH/laUx0cK7S0BjusTT+OtOOJOamZM4+93RHdU=", + "lastModified": 1675708067, + "narHash": "sha256-DxpcPTBlvVP88PDoTheLV2fC76EXDqS2UpM5mAfj/D4=", "owner": "hrsh7th", "repo": "cmp-nvim-lsp", - "rev": "59224771f91b86d1de12570b4070fe4ad7cd1eeb", + "rev": "0e6b2ed705ddcff9738ec4ea838141654f12eeef", "type": "github" }, "original": { @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1675299131, - "narHash": "sha256-tMQKjyKTe4H4X5UsRpwbjKuKoOUkPFpjn9DqvB6/ijA=", + "lastModified": 1675471726, + "narHash": "sha256-526iHwidfdtZZ7aAU9od1/zbyfSFBEailBTet+Gvfqg=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "c4ed0e71e6ecb44b1237aa6acb70aaa0b6e924fa", + "rev": "813d55a3e3b3c0423eb5d1fcb4bf82197c9f7796", "type": "github" }, "original": { @@ -156,11 +156,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1675371293, - "narHash": "sha256-LrCjtrAXj/WJphhGEMnHgZs7oTsfOlvPfOjFTIvg39k=", + "lastModified": 1675935446, + "narHash": "sha256-WajulTn7QdwC7QuXRBavrANuIXE5z+08EdxdRw1qsNs=", "owner": "nix-community", "repo": "home-manager", - "rev": "d1c7730bb707bf8124d997952f7babd2a281ae68", + "rev": "2dce7f1a55e785a22d61668516df62899278c9e4", "type": "github" }, "original": { @@ -177,11 +177,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1675427255, - "narHash": "sha256-d53add4Cuh0ik8YYncdoqqR6irQbnh/X4vg12TQ/FEQ=", + "lastModified": 1676110678, + "narHash": "sha256-hemg8rMKS2me2Wua9ZG/0aQ8fEOfytjyKB+WYcXfEKE=", "owner": "oxalica", "repo": "nil", - "rev": "3de72eefd8114b30f8ea82ead846a9401c262475", + "rev": "ce2e0b5d60fe497134050796f7d12ffb6b50eb28", "type": "github" }, "original": { @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1675183161, - "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", + "lastModified": 1676110339, + "narHash": "sha256-kOS/L8OOL2odpCOM11IevfHxcUeE0vnZUQ74EOiwXcs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", + "rev": "e5530aba13caff5a4f41713f1265b754dc2abfd8", "type": "github" }, "original": { @@ -314,11 +314,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1675186656, - "narHash": "sha256-pucn9YCeQaOVXCrH+C42C8hkfMsYcxRkdjQbb223qhA=", + "lastModified": 1676246878, + "narHash": "sha256-hAUEa2zNsYXQ+TsHYHBzcW67lCxhiD7x+uPbdOZwY8o=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "c3e678110d5f31854c6575cf4bda3b82f3d4a884", + "rev": "d4594231a06cecce73a78a256b0d7c7ab51f7dd5", "type": "github" }, "original": { @@ -329,11 +329,11 @@ }, "nur": { "locked": { - "lastModified": 1675390386, - "narHash": "sha256-VK1EGF9+U2A72Gy5lgHHa6DaGOnx3Ml51E0TewYh5L8=", + "lastModified": 1676251563, + "narHash": "sha256-itLKR2Haeh5wQ6dxkuZ8L5gwp3+CAggpN+w2e7cLQPg=", "owner": "nix-community", "repo": "nur", - "rev": "f9a67871a7c1dcd424a20b6e3723eacc0704bc97", + "rev": "9a8b28a9d6611f6af9f7abb3e690fc755d6906fe", "type": "github" }, "original": { @@ -345,11 +345,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1675162896, - "narHash": "sha256-2XmfhBldseP9zxrQBFtapUpMBIkhKgyiM+xUbP+os8I=", + "lastModified": 1676175675, + "narHash": "sha256-Wg3NatT4DRBMF6hCxK4C2DC+geFMpfFUFogPbqeMt6E=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "902d6aa31450d26e11bedcbef8af5b6fe2e1ffe8", + "rev": "1712672e4da3003a0dd9f771d30389600b360f42", "type": "github" }, "original": { @@ -361,11 +361,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1675128430, - "narHash": "sha256-gs50ubONKCxxXfR6wu6238s71R5Gmaot3unxpMFZOwM=", + "lastModified": 1676244722, + "narHash": "sha256-xoSekdZhWr59qTOM0/ihYiuKiwHiKYb42Ep5JHn65UM=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "215b29bfad74518442621b9d0483a621483b066b", + "rev": "ba1778e061f25814bc5940be886a7f41d7d7736e", "type": "github" }, "original": { @@ -377,11 +377,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1675373326, - "narHash": "sha256-uC5AMeoWvjxf4b7Mysnsze/SRTawRjS9pBddMveUNYI=", + "lastModified": 1676240774, + "narHash": "sha256-eRSU/9ysSvTyYxBrp9Whg0eXgAOsCdmIHMlYZK7bjRg=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "660a070af7131387c690c7b839718371916e27f9", + "rev": "7eb5f1a2e3949496f26c4084b521b30f2d08137a", "type": "github" }, "original": { @@ -525,11 +525,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1675351082, - "narHash": "sha256-4Oi4k4Qp1vOvKoACHDcz0xiVj7DuMaCL57fP3W77eA0=", + "lastModified": 1676126384, + "narHash": "sha256-3aAnN891Cb1pizewAgaHIo3W1WbAjXtoWuX8n3j8YoI=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "52cadf92e1bfdef235d5cd77b9a4b2ab848baa8a", + "rev": "a1c7e8bebac32cfac7aa8498bdfc60cbff13eb50", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6086814..4f0f859 100644 --- a/flake.nix +++ b/flake.nix @@ -132,7 +132,7 @@ darwinConfigurations = { lookingglass = - import ./hosts/macbook { inherit inputs globals overlays; }; + import ./hosts/lookingglass { inherit inputs globals overlays; }; }; # For quickly applying local settings with: diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 0e65d67..a23d530 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -24,29 +24,29 @@ enable = true; package = if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - ublock-origin - vimium - multi-account-containers - facebook-container - temporary-containers - (lib.mkIf config."1password".enable onepassword-password-manager) - okta-browser-plugin - sponsorblock - reddit-enhancement-suite - return-youtube-dislikes - bypass-paywalls-clean - markdownload - darkreader - snowflake - don-t-fuck-with-paste - i-dont-care-about-cookies - wappalyzer - ]; profiles.default = { id = 0; name = "default"; isDefault = true; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + ublock-origin + vimium + multi-account-containers + facebook-container + temporary-containers + (lib.mkIf config."1password".enable onepassword-password-manager) + okta-browser-plugin + sponsorblock + reddit-enhancement-suite + return-youtube-dislikes + bypass-paywalls-clean + markdownload + darkreader + snowflake + don-t-fuck-with-paste + i-dont-care-about-cookies + wappalyzer + ]; settings = { "app.update.auto" = false; "browser.aboutConfig.showWarning" = false; From e8c5a10df7ac2bae9a0432d10b65478727ba0438 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:14:57 -0500 Subject: [PATCH 177/391] attempt to set default apps for xdg-open --- modules/applications/media.nix | 21 +++++++++++++++------ modules/applications/nautilus.nix | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/applications/media.nix b/modules/applications/media.nix index c2a1620..84fe7eb 100644 --- a/modules/applications/media.nix +++ b/modules/applications/media.nix @@ -10,12 +10,21 @@ }; config = lib.mkIf (config.gui.enable && config.media.enable) { - home-manager.users.${config.user}.home.packages = with pkgs; [ - mpv # Video viewer - sxiv # Image viewer - mupdf # PDF viewer - zathura # PDF viewer - ]; + home-manager.users.${config.user} = { + home.packages = with pkgs; [ + mpv # Video viewer + sxiv # Image viewer + mupdf # PDF viewer + zathura # PDF viewer + ]; + + # Set default for opening PDFs + xdg.mimeApps.defaultApplications."application/pdf" = + [ "zathura.desktop" ]; + xdg.mimeApps.defaultApplications."image/*" = [ "sxiv.desktop" ]; + + }; + }; } diff --git a/modules/applications/nautilus.nix b/modules/applications/nautilus.nix index 3c81b0b..d8610e6 100644 --- a/modules/applications/nautilus.nix +++ b/modules/applications/nautilus.nix @@ -17,6 +17,10 @@ gnome.sushi # Quick preview with spacebar ]; + # Set default for opening directories + xdg.mimeApps.defaultApplications."inode/directory" = + [ "nautilus.desktop" ]; + programs.fish.functions = { qr = { body = From 58a0e6166dfe442b6949f89ec1784ba5f7b451fe Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 17 Feb 2023 18:15:23 -0500 Subject: [PATCH 178/391] allow reading windows ntfs drives --- nixos/hardware/boot.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/hardware/boot.nix b/nixos/hardware/boot.nix index 3d30be8..875b586 100644 --- a/nixos/hardware/boot.nix +++ b/nixos/hardware/boot.nix @@ -35,4 +35,9 @@ # Allows GRUB to interact with the UEFI/BIOS I guess efi.canTouchEfiVariables = true; }; + + # Allow reading from Windows drives + boot.supportedFilesystems = + lib.mkIf (config.physical && pkgs.stdenv.isLinux) [ "ntfs" ]; + } From 6577b9e49b28c4bb69b17e682230fdb6c03c4f60 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 18 Feb 2023 10:24:54 -0500 Subject: [PATCH 179/391] initial setup for swan and staff --- flake.nix | 9 ++++- {hosts => generators}/aws/default.nix | 0 {hosts => generators}/aws/main.tf | 0 {hosts => generators}/aws/workflow.yml | 0 generators/staff/default.nix | 17 +++++++++ hosts/swan/default.nix | 48 ++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 1 deletion(-) rename {hosts => generators}/aws/default.nix (100%) rename {hosts => generators}/aws/main.tf (100%) rename {hosts => generators}/aws/workflow.yml (100%) create mode 100644 generators/staff/default.nix create mode 100644 hosts/swan/default.nix diff --git a/flake.nix b/flake.nix index 4f0f859..32a5875 100644 --- a/flake.nix +++ b/flake.nix @@ -128,6 +128,7 @@ tempest = import ./hosts/tempest { inherit inputs globals overlays; }; hydra = import ./hosts/hydra { inherit inputs globals overlays; }; flame = import ./hosts/flame { inherit inputs globals overlays; }; + swan = import ./hosts/swan { inherit inputs globals overlays; }; }; darwinConfigurations = { @@ -149,7 +150,13 @@ aws = { "${system}" = - import ./hosts/aws { inherit inputs globals system overlays; }; + import ./generators/aws { inherit inputs globals system overlays; }; + }; + + staff = { + "${system}" = import ./generators/staff { + inherit inputs globals system overlays; + }; }; neovim = let pkgs = import nixpkgs { inherit system overlays; }; diff --git a/hosts/aws/default.nix b/generators/aws/default.nix similarity index 100% rename from hosts/aws/default.nix rename to generators/aws/default.nix diff --git a/hosts/aws/main.tf b/generators/aws/main.tf similarity index 100% rename from hosts/aws/main.tf rename to generators/aws/main.tf diff --git a/hosts/aws/workflow.yml b/generators/aws/workflow.yml similarity index 100% rename from hosts/aws/workflow.yml rename to generators/aws/workflow.yml diff --git a/generators/staff/default.nix b/generators/staff/default.nix new file mode 100644 index 0000000..01555f2 --- /dev/null +++ b/generators/staff/default.nix @@ -0,0 +1,17 @@ +# The Staff +# ISO configuration for my USB drive + +{ inputs, globals, overlays, ... }: + +with inputs; + +nixos-generators.nixosGenerate { + inherit system; + format = "install-iso"; + modules = [{ + networking.hostName = "staff"; + users.extraUsers.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s" + ]; + }]; +} diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix new file mode 100644 index 0000000..fee6e9e --- /dev/null +++ b/hosts/swan/default.nix @@ -0,0 +1,48 @@ +# The Swan +# System configuration for my home NAS server + +{ inputs, globals, overlays, ... }: + +with inputs; + +nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { }; + modules = [ + ./hardware-configuration.nix + ../../modules + ../../nixos + (removeAttrs globals [ "mail.server" ]) + wsl.nixosModules.wsl + home-manager.nixosModules.home-manager + { + server = true; + gui.enable = false; + theme = { colors = (import ../../colorscheme/gruvbox).dark; }; + nixpkgs.overlays = overlays; + wsl.enable = false; + caddy.enable = true; + + networking.hostName = "swan"; + + # Disable passwords, only use SSH key + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; + + # Clone dotfiles + dotfiles.enable = true; + + neovim.enable = true; + + boot.zfs.enabled = true; + boot.kernelPackages = + config.boot.zfs.package.latestCompatibleLinuxPackages; + boot.zfs.extraPools = [ "mypool" ]; + services.zfs.autoScrub.enable = true; + services.zfs.autoScrub.interval = "daily"; + + services.nfs.server.enable = true; + + } + ]; +} From 07e0afa1e9d73d10a6c13f7a145527d21b1efa87 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:32:14 -0500 Subject: [PATCH 180/391] fix: iso generating --- generators/staff/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/staff/default.nix b/generators/staff/default.nix index 01555f2..2f225b2 100644 --- a/generators/staff/default.nix +++ b/generators/staff/default.nix @@ -1,7 +1,7 @@ # The Staff # ISO configuration for my USB drive -{ inputs, globals, overlays, ... }: +{ inputs, globals, system, overlays, ... }: with inputs; From 700e59e6c84b3b99d836b6a683697a073540ebc0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:48:11 -0500 Subject: [PATCH 181/391] update outdated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 244ed4d..60efdc9 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ following command: ```bash nix-shell -p nixVersions.stable -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#desktop +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#tempest ``` ## Windows - From NixOS WSL From 048de4772c318b3c61a30c350a39518ddc93c3cb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:49:00 -0500 Subject: [PATCH 182/391] rename 1password module with underscore --- hosts/tempest/default.nix | 2 +- modules/applications/1password.nix | 4 ++-- modules/applications/firefox.nix | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix index 73e8216..b6a6ab7 100644 --- a/hosts/tempest/default.nix +++ b/hosts/tempest/default.nix @@ -37,7 +37,7 @@ nixpkgs.lib.nixosSystem { media.enable = true; firefox.enable = true; kitty.enable = true; - "1password".enable = true; + _1password.enable = true; discord.enable = true; nautilus.enable = true; obsidian.enable = true; diff --git a/modules/applications/1password.nix b/modules/applications/1password.nix index 9a31c03..13ada8a 100644 --- a/modules/applications/1password.nix +++ b/modules/applications/1password.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: { options = { - "1password" = { + _1password = { enable = lib.mkEnableOption { description = "Enable 1Password."; default = false; @@ -10,7 +10,7 @@ }; config = lib.mkIf - (config.gui.enable && config."1password".enable && pkgs.stdenv.isLinux) { + (config.gui.enable && config._1password.enable && pkgs.stdenv.isLinux) { unfreePackages = [ "1password" "_1password-gui" ]; home-manager.users.${config.user} = { home.packages = with pkgs; [ _1password-gui ]; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index a23d530..0dc1b66 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -14,7 +14,7 @@ config = lib.mkIf (config.gui.enable && config.firefox.enable) { unfreePackages = [ - (lib.mkIf config."1password".enable "onepassword-password-manager") + (lib.mkIf config._1password.enable "onepassword-password-manager") "okta-browser-plugin" ]; @@ -34,7 +34,7 @@ multi-account-containers facebook-container temporary-containers - (lib.mkIf config."1password".enable onepassword-password-manager) + (lib.mkIf config._1password.enable onepassword-password-manager) okta-browser-plugin sponsorblock reddit-enhancement-suite From 6cd22bc7ced508a61028189b2ffb55a91b418664 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:49:19 -0500 Subject: [PATCH 183/391] remove bypass-paywalls-clean no longer available from mozilla extensions --- modules/applications/firefox.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 0dc1b66..4b809c0 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -39,7 +39,6 @@ sponsorblock reddit-enhancement-suite return-youtube-dislikes - bypass-paywalls-clean markdownload darkreader snowflake From 86aa02aae4258acc274e620ab9c3f00ae3b586ef Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:00:54 -0500 Subject: [PATCH 184/391] rename patches directory to overlays --- flake.nix | 3 ++- nixos/services/calibre.nix | 10 ---------- {patches => overlays}/calibre-web-cloudflare.patch | 0 overlays/calibre-web.nix | 7 +++++++ .../plugins-overlay.nix => overlays/neovim-plugins.nix | 0 5 files changed, 9 insertions(+), 11 deletions(-) rename {patches => overlays}/calibre-web-cloudflare.patch (100%) create mode 100644 overlays/calibre-web.nix rename modules/neovim/plugins-overlay.nix => overlays/neovim-plugins.nix (100%) diff --git a/flake.nix b/flake.nix index 32a5875..3841029 100644 --- a/flake.nix +++ b/flake.nix @@ -112,7 +112,8 @@ overlays = [ inputs.nur.overlay inputs.nix2vim.overlay - (import ./modules/neovim/plugins-overlay.nix inputs) + (import ./overlays/neovim-plugins.nix inputs) + (import ./overlays/calibre-web.nix) ]; # System types to support. diff --git a/nixos/services/calibre.nix b/nixos/services/calibre.nix index 1637244..c596303 100644 --- a/nixos/services/calibre.nix +++ b/nixos/services/calibre.nix @@ -20,16 +20,6 @@ }; }; - # Fix: https://github.com/janeczku/calibre-web/issues/2422 - nixpkgs.overlays = [ - (final: prev: { - calibre-web = prev.calibre-web.overrideAttrs (old: { - patches = (old.patches or [ ]) - ++ [ ../../patches/calibre-web-cloudflare.patch ]; - }); - }) - ]; - caddy.routes = [{ match = [{ host = [ config.bookServer ]; }]; handle = [{ diff --git a/patches/calibre-web-cloudflare.patch b/overlays/calibre-web-cloudflare.patch similarity index 100% rename from patches/calibre-web-cloudflare.patch rename to overlays/calibre-web-cloudflare.patch diff --git a/overlays/calibre-web.nix b/overlays/calibre-web.nix new file mode 100644 index 0000000..6717ec4 --- /dev/null +++ b/overlays/calibre-web.nix @@ -0,0 +1,7 @@ +# Fix: https://github.com/janeczku/calibre-web/issues/2422 + +final: prev: { + calibre-web = prev.calibre-web.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ./calibre-web-cloudflare.patch ]; + }); +} diff --git a/modules/neovim/plugins-overlay.nix b/overlays/neovim-plugins.nix similarity index 100% rename from modules/neovim/plugins-overlay.nix rename to overlays/neovim-plugins.nix From 448c97665b611e9684218508cb071b4aa0055814 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:02:21 -0500 Subject: [PATCH 185/391] move public-keys to root directory --- apps/encrypt-secret.nix | 2 +- apps/reencrypt-secrets.nix | 2 +- hosts/public-keys => public-keys | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename hosts/public-keys => public-keys (100%) diff --git a/apps/encrypt-secret.nix b/apps/encrypt-secret.nix index 325d942..7e83cba 100644 --- a/apps/encrypt-secret.nix +++ b/apps/encrypt-secret.nix @@ -11,7 +11,7 @@ tmpfile=$(mktemp) echo "''${secret}" > ''${tmpfile} ${pkgs.age}/bin/age --encrypt --armor --recipients-file ${ - builtins.toString ../hosts/public-keys + builtins.toString ../public-keys } $tmpfile rm $tmpfile ''); diff --git a/apps/reencrypt-secrets.nix b/apps/reencrypt-secrets.nix index f1c2c2d..24c21c9 100644 --- a/apps/reencrypt-secrets.nix +++ b/apps/reencrypt-secrets.nix @@ -17,7 +17,7 @@ --identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile echo "Encrypting ''${encryptedfile}..." ${pkgs.age}/bin/age --encrypt --armor --recipients-file ${ - builtins.toString ../hosts/public-keys + builtins.toString ../public-keys } $tmpfile > $encryptedfile rm $tmpfile done diff --git a/hosts/public-keys b/public-keys similarity index 100% rename from hosts/public-keys rename to public-keys From 251dce68bbb66c02b63194500672e03dd7f580b8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:13:52 -0500 Subject: [PATCH 186/391] remove mitm ssl instructions --- README.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 60efdc9..ede0f40 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ the WSL configuration: ``` nix-shell -p nixVersions.stable -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#wsl +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#flame ``` You should also download the @@ -90,17 +90,7 @@ nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer Then switch to the macOS configuration: ```bash -darwin-rebuild switch --flake github:nmasur/dotfiles#macbook -``` - -### Dealing with corporate MITM SSL certificates: - -```bash -# Get the certificates -openssl s_client -showcerts -verify 5 -connect cache.nixos.org:443 < /dev/null - -# Paste them in here -sudo nvim $NIX_SSL_CERT_FILE +darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass ``` --- From 0d0ee1fc5a99f2890e2ee94ae9855c59725bd6f4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:26:14 -0500 Subject: [PATCH 187/391] improve readme clarity --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ede0f40..22a4b42 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# System Configurations + This repository contains configuration files for my NixOS, macOS, and WSL hosts. @@ -12,25 +14,25 @@ However, some of the configurations are easier to lift directly: - [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/git.nix) - [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon) -Try out my Neovim config: +Try out my Neovim config (requires [nix](https://nixos.org/download.html)): ```bash nix run github:nmasur/dotfiles#neovim ``` -Or build it as a package: +Or build it as a package (requires [nix](https://nixos.org/download.html)): ```bash nix build github:nmasur/dotfiles#neovim ``` If you already have a Neovim configuration, you may need to move it out of -`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise, both +`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise both configs might conflict with each other. --- -# Installation +# Full Installation ## NixOS - From Live Disk @@ -42,7 +44,7 @@ installer disk: ```bash lsblk # Choose the disk you want to wipe nix-shell -p nixVersions.stable -nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop +nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest ``` ## NixOS - From Existing System @@ -63,7 +65,7 @@ the WSL configuration: ``` nix-shell -p nixVersions.stable -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#flame +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#hydra ``` You should also download the From ded498f4c91f287ea08c2adeb5bad4d8a3f56acf Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:30:45 -0500 Subject: [PATCH 188/391] switch from uuid to label disks --- hosts/tempest/hardware-configuration.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hosts/tempest/hardware-configuration.nix b/hosts/tempest/hardware-configuration.nix index 82abb50..bf692e8 100644 --- a/hosts/tempest/hardware-configuration.nix +++ b/hosts/tempest/hardware-configuration.nix @@ -15,12 +15,12 @@ services.xserver.videoDrivers = [ "amdgpu" ]; fileSystems."/" = { - device = "/dev/disk/by-uuid/f0313f58-971a-46e3-9191-909fe5eb7f7e"; + device = "/dev/disk/by-label/nixos"; fsType = "ext4"; }; fileSystems."/boot" = { - device = "/dev/disk/by-uuid/FB26-799C"; + device = "/dev/disk/by-label/boot"; fsType = "vfat"; }; @@ -34,7 +34,7 @@ # networking.interfaces.enp5s0.useDHCP = lib.mkDefault true; # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; - powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } From cc84f1d37ab9e7a842e7999368d18165978744dd Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:37:37 -0500 Subject: [PATCH 189/391] move nixos and darwin back into modules dir --- README.md | 8 ++++---- apps/default.nix | 2 +- flake.nix | 2 +- generators/aws/default.nix | 6 +++--- hosts/flame/default.nix | 4 ++-- hosts/hydra/default.nix | 4 ++-- hosts/lookingglass/default.nix | 4 ++-- hosts/swan/default.nix | 4 ++-- hosts/tempest/default.nix | 4 ++-- .../{ => common}/applications/1password.nix | 0 .../{ => common}/applications/alacritty.nix | 0 modules/{ => common}/applications/default.nix | 0 modules/{ => common}/applications/discord.nix | 0 modules/{ => common}/applications/firefox.nix | 0 modules/{ => common}/applications/kitty.nix | 0 modules/{ => common}/applications/media.nix | 0 .../{ => common}/applications/nautilus.nix | 0 .../{ => common}/applications/obsidian.nix | 0 .../{ => common}/applications/qbittorrent.nix | 0 modules/{ => common}/default.nix | 0 modules/{ => common}/mail/aerc.nix | 0 modules/{ => common}/mail/default.nix | 0 modules/{ => common}/mail/himalaya.nix | 0 .../{ => common}/neovim/config/bufferline.nix | 0 .../{ => common}/neovim/config/completion.nix | 0 .../{ => common}/neovim/config/gitsigns.lua | 0 .../{ => common}/neovim/config/gitsigns.nix | 0 modules/{ => common}/neovim/config/lsp.lua | 0 modules/{ => common}/neovim/config/lsp.nix | 0 modules/{ => common}/neovim/config/misc.nix | 0 .../{ => common}/neovim/config/statusline.nix | 0 modules/{ => common}/neovim/config/syntax.nix | 0 .../{ => common}/neovim/config/telescope.lua | 0 .../{ => common}/neovim/config/telescope.nix | 0 .../{ => common}/neovim/config/toggleterm.lua | 0 .../{ => common}/neovim/config/toggleterm.nix | 0 modules/{ => common}/neovim/config/tree.nix | 0 modules/{ => common}/neovim/default.nix | 0 modules/{ => common}/neovim/init.lua | 0 modules/{ => common}/neovim/lua/keybinds.lua | 0 .../neovim/lua/packer/completion.lua | 0 .../{ => common}/neovim/lua/packer/lsp.lua | 0 .../{ => common}/neovim/lua/packer/misc.lua | 0 .../{ => common}/neovim/lua/packer/speed.lua | 0 .../{ => common}/neovim/lua/packer/syntax.lua | 0 .../neovim/lua/packer/telescope.lua | 0 .../neovim/lua/packer/toggleterm.lua | 0 .../neovim/lua/packer/visuals.lua | 0 .../{ => common}/neovim/lua/packer_init.lua | 0 modules/{ => common}/neovim/lua/settings.lua | 0 .../{ => common}/neovim/package/default.nix | 20 +++++++++---------- modules/{ => common}/programming/default.nix | 0 modules/{ => common}/programming/haskell.nix | 0 .../{ => common}/programming/kubernetes.nix | 0 modules/{ => common}/programming/lua.nix | 0 modules/{ => common}/programming/nix.nix | 0 modules/{ => common}/programming/python.nix | 0 .../{ => common}/programming/terraform.nix | 0 modules/{ => common}/repositories/default.nix | 0 .../{ => common}/repositories/dotfiles.nix | 0 modules/{ => common}/repositories/notes.nix | 0 .../{ => common}/shell/bash/scripts/ocr.sh | 0 modules/{ => common}/shell/charm.nix | 0 modules/{ => common}/shell/default.nix | 0 modules/{ => common}/shell/direnv.nix | 0 modules/{ => common}/shell/fish/default.nix | 0 .../functions/commandline-git-commits.fish | 0 .../shell/fish/functions/edit.fish | 0 .../shell/fish/functions/fcd.fish | 0 .../functions/fish_user_key_bindings.fish | 0 .../shell/fish/functions/fish_vi_cursor.fish | 0 .../shell/fish/functions/git-add-fuzzy.fish | 0 .../shell/fish/functions/git-commits.fish | 0 .../fish/functions/git-fuzzy-branch.fish | 0 .../shell/fish/functions/git-history.fish | 0 .../fish/functions/git-push-upstream.fish | 0 .../shell/fish/functions/git-show-fuzzy.fish | 0 .../shell/fish/functions/git.fish | 0 .../{ => common}/shell/fish/functions/ip.fish | 0 .../shell/fish/functions/note.fish | 0 .../shell/fish/functions/recent.fish | 0 .../shell/fish/functions/search-and-edit.fish | 0 .../shell/fish/functions/syncnotes.fish | 0 .../shell/fish/functions/uncommitted.fish | 0 modules/{ => common}/shell/fzf.nix | 0 modules/{ => common}/shell/git.nix | 0 modules/{ => common}/shell/github.nix | 0 modules/{ => common}/shell/nixpkgs.nix | 0 modules/{ => common}/shell/starship.nix | 0 modules/{ => common}/shell/utilities.nix | 0 {darwin => modules/darwin}/alacritty.nix | 0 {darwin => modules/darwin}/default.nix | 0 {darwin => modules/darwin}/fonts.nix | 0 {darwin => modules/darwin}/hammerspoon.nix | 0 .../darwin}/hammerspoon/.stylua.toml | 0 .../Spoons/ControlEscape.spoon/init.lua | 0 .../close_notifications_applescript.js | 0 .../Spoons/DismissAlerts.spoon/init.lua | 0 .../Spoons/Launcher.spoon/init.lua | 0 .../Spoons/MoveWindow.spoon/init.lua | 0 .../Spoons/MoveWindow.spoon/worklayout.lua | 0 .../darwin}/hammerspoon/init.lua | 0 {darwin => modules/darwin}/homebrew.nix | 0 {darwin => modules/darwin}/kitty.nix | 0 {darwin => modules/darwin}/networking.nix | 0 {darwin => modules/darwin}/nixpkgs.nix | 0 {darwin => modules/darwin}/system.nix | 0 {darwin => modules/darwin}/tmux.nix | 0 {darwin => modules/darwin}/user.nix | 0 {darwin => modules/darwin}/utilities.nix | 2 +- .../nixos}/applications/calibre.nix | 0 .../nixos}/applications/default.nix | 0 {nixos => modules/nixos}/default.nix | 0 {nixos => modules/nixos}/gaming/default.nix | 0 .../nixos}/gaming/leagueoflegends.nix | 0 {nixos => modules/nixos}/gaming/legendary.nix | 0 {nixos => modules/nixos}/gaming/lutris.nix | 0 .../nixos}/gaming/minecraft-server.nix | 0 {nixos => modules/nixos}/gaming/steam.nix | 0 .../nixos}/graphical/default.nix | 0 {nixos => modules/nixos}/graphical/dmenu.nix | 0 {nixos => modules/nixos}/graphical/fonts.nix | 0 {nixos => modules/nixos}/graphical/i3.nix | 0 {nixos => modules/nixos}/graphical/picom.nix | 0 .../nixos}/graphical/polybar.nix | 0 {nixos => modules/nixos}/graphical/rofi.nix | 0 .../nixos}/graphical/rofi/brightness.sh | 0 {nixos => modules/nixos}/graphical/xorg.nix | 0 {nixos => modules/nixos}/hardware/audio.nix | 0 {nixos => modules/nixos}/hardware/boot.nix | 0 {nixos => modules/nixos}/hardware/default.nix | 0 .../nixos}/hardware/keyboard.nix | 0 .../nixos}/hardware/monitors.nix | 0 {nixos => modules/nixos}/hardware/mouse.nix | 0 .../nixos}/hardware/networking.nix | 0 {nixos => modules/nixos}/hardware/server.nix | 0 {nixos => modules/nixos}/hardware/sleep.nix | 0 {nixos => modules/nixos}/hardware/wifi.nix | 0 {nixos => modules/nixos}/services/backups.nix | 0 {nixos => modules/nixos}/services/caddy.nix | 0 {nixos => modules/nixos}/services/calibre.nix | 0 .../nixos}/services/cloudflare.nix | 0 {nixos => modules/nixos}/services/default.nix | 0 {nixos => modules/nixos}/services/gitea.nix | 0 {nixos => modules/nixos}/services/gnupg.nix | 0 .../nixos}/services/honeypot.nix | 0 .../nixos}/services/jellyfin.nix | 0 {nixos => modules/nixos}/services/keybase.nix | 0 {nixos => modules/nixos}/services/mullvad.nix | 0 {nixos => modules/nixos}/services/n8n.nix | 0 {nixos => modules/nixos}/services/netdata.nix | 0 .../nixos}/services/nextcloud.nix | 0 .../nixos}/services/prometheus.nix | 0 {nixos => modules/nixos}/services/secrets.nix | 0 {nixos => modules/nixos}/services/sshd.nix | 0 .../nixos}/services/transmission.nix | 0 .../nixos}/services/vaultwarden.nix | 0 .../nixos}/services/wireguard.nix | 0 {nixos => modules/nixos}/system/default.nix | 0 {nixos => modules/nixos}/system/doas.nix | 0 {nixos => modules/nixos}/system/timezone.nix | 0 {nixos => modules/nixos}/system/user.nix | 0 {nixos => modules/nixos}/wsl/default.nix | 0 163 files changed, 30 insertions(+), 30 deletions(-) rename modules/{ => common}/applications/1password.nix (100%) rename modules/{ => common}/applications/alacritty.nix (100%) rename modules/{ => common}/applications/default.nix (100%) rename modules/{ => common}/applications/discord.nix (100%) rename modules/{ => common}/applications/firefox.nix (100%) rename modules/{ => common}/applications/kitty.nix (100%) rename modules/{ => common}/applications/media.nix (100%) rename modules/{ => common}/applications/nautilus.nix (100%) rename modules/{ => common}/applications/obsidian.nix (100%) rename modules/{ => common}/applications/qbittorrent.nix (100%) rename modules/{ => common}/default.nix (100%) rename modules/{ => common}/mail/aerc.nix (100%) rename modules/{ => common}/mail/default.nix (100%) rename modules/{ => common}/mail/himalaya.nix (100%) rename modules/{ => common}/neovim/config/bufferline.nix (100%) rename modules/{ => common}/neovim/config/completion.nix (100%) rename modules/{ => common}/neovim/config/gitsigns.lua (100%) rename modules/{ => common}/neovim/config/gitsigns.nix (100%) rename modules/{ => common}/neovim/config/lsp.lua (100%) rename modules/{ => common}/neovim/config/lsp.nix (100%) rename modules/{ => common}/neovim/config/misc.nix (100%) rename modules/{ => common}/neovim/config/statusline.nix (100%) rename modules/{ => common}/neovim/config/syntax.nix (100%) rename modules/{ => common}/neovim/config/telescope.lua (100%) rename modules/{ => common}/neovim/config/telescope.nix (100%) rename modules/{ => common}/neovim/config/toggleterm.lua (100%) rename modules/{ => common}/neovim/config/toggleterm.nix (100%) rename modules/{ => common}/neovim/config/tree.nix (100%) rename modules/{ => common}/neovim/default.nix (100%) rename modules/{ => common}/neovim/init.lua (100%) rename modules/{ => common}/neovim/lua/keybinds.lua (100%) rename modules/{ => common}/neovim/lua/packer/completion.lua (100%) rename modules/{ => common}/neovim/lua/packer/lsp.lua (100%) rename modules/{ => common}/neovim/lua/packer/misc.lua (100%) rename modules/{ => common}/neovim/lua/packer/speed.lua (100%) rename modules/{ => common}/neovim/lua/packer/syntax.lua (100%) rename modules/{ => common}/neovim/lua/packer/telescope.lua (100%) rename modules/{ => common}/neovim/lua/packer/toggleterm.lua (100%) rename modules/{ => common}/neovim/lua/packer/visuals.lua (100%) rename modules/{ => common}/neovim/lua/packer_init.lua (100%) rename modules/{ => common}/neovim/lua/settings.lua (100%) rename modules/{ => common}/neovim/package/default.nix (59%) rename modules/{ => common}/programming/default.nix (100%) rename modules/{ => common}/programming/haskell.nix (100%) rename modules/{ => common}/programming/kubernetes.nix (100%) rename modules/{ => common}/programming/lua.nix (100%) rename modules/{ => common}/programming/nix.nix (100%) rename modules/{ => common}/programming/python.nix (100%) rename modules/{ => common}/programming/terraform.nix (100%) rename modules/{ => common}/repositories/default.nix (100%) rename modules/{ => common}/repositories/dotfiles.nix (100%) rename modules/{ => common}/repositories/notes.nix (100%) rename modules/{ => common}/shell/bash/scripts/ocr.sh (100%) rename modules/{ => common}/shell/charm.nix (100%) rename modules/{ => common}/shell/default.nix (100%) rename modules/{ => common}/shell/direnv.nix (100%) rename modules/{ => common}/shell/fish/default.nix (100%) rename modules/{ => common}/shell/fish/functions/commandline-git-commits.fish (100%) rename modules/{ => common}/shell/fish/functions/edit.fish (100%) rename modules/{ => common}/shell/fish/functions/fcd.fish (100%) rename modules/{ => common}/shell/fish/functions/fish_user_key_bindings.fish (100%) rename modules/{ => common}/shell/fish/functions/fish_vi_cursor.fish (100%) rename modules/{ => common}/shell/fish/functions/git-add-fuzzy.fish (100%) rename modules/{ => common}/shell/fish/functions/git-commits.fish (100%) rename modules/{ => common}/shell/fish/functions/git-fuzzy-branch.fish (100%) rename modules/{ => common}/shell/fish/functions/git-history.fish (100%) rename modules/{ => common}/shell/fish/functions/git-push-upstream.fish (100%) rename modules/{ => common}/shell/fish/functions/git-show-fuzzy.fish (100%) rename modules/{ => common}/shell/fish/functions/git.fish (100%) rename modules/{ => common}/shell/fish/functions/ip.fish (100%) rename modules/{ => common}/shell/fish/functions/note.fish (100%) rename modules/{ => common}/shell/fish/functions/recent.fish (100%) rename modules/{ => common}/shell/fish/functions/search-and-edit.fish (100%) rename modules/{ => common}/shell/fish/functions/syncnotes.fish (100%) rename modules/{ => common}/shell/fish/functions/uncommitted.fish (100%) rename modules/{ => common}/shell/fzf.nix (100%) rename modules/{ => common}/shell/git.nix (100%) rename modules/{ => common}/shell/github.nix (100%) rename modules/{ => common}/shell/nixpkgs.nix (100%) rename modules/{ => common}/shell/starship.nix (100%) rename modules/{ => common}/shell/utilities.nix (100%) rename {darwin => modules/darwin}/alacritty.nix (100%) rename {darwin => modules/darwin}/default.nix (100%) rename {darwin => modules/darwin}/fonts.nix (100%) rename {darwin => modules/darwin}/hammerspoon.nix (100%) rename {darwin => modules/darwin}/hammerspoon/.stylua.toml (100%) rename {darwin => modules/darwin}/hammerspoon/Spoons/ControlEscape.spoon/init.lua (100%) rename {darwin => modules/darwin}/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js (100%) rename {darwin => modules/darwin}/hammerspoon/Spoons/DismissAlerts.spoon/init.lua (100%) rename {darwin => modules/darwin}/hammerspoon/Spoons/Launcher.spoon/init.lua (100%) rename {darwin => modules/darwin}/hammerspoon/Spoons/MoveWindow.spoon/init.lua (100%) rename {darwin => modules/darwin}/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua (100%) rename {darwin => modules/darwin}/hammerspoon/init.lua (100%) rename {darwin => modules/darwin}/homebrew.nix (100%) rename {darwin => modules/darwin}/kitty.nix (100%) rename {darwin => modules/darwin}/networking.nix (100%) rename {darwin => modules/darwin}/nixpkgs.nix (100%) rename {darwin => modules/darwin}/system.nix (100%) rename {darwin => modules/darwin}/tmux.nix (100%) rename {darwin => modules/darwin}/user.nix (100%) rename {darwin => modules/darwin}/utilities.nix (95%) rename {nixos => modules/nixos}/applications/calibre.nix (100%) rename {nixos => modules/nixos}/applications/default.nix (100%) rename {nixos => modules/nixos}/default.nix (100%) rename {nixos => modules/nixos}/gaming/default.nix (100%) rename {nixos => modules/nixos}/gaming/leagueoflegends.nix (100%) rename {nixos => modules/nixos}/gaming/legendary.nix (100%) rename {nixos => modules/nixos}/gaming/lutris.nix (100%) rename {nixos => modules/nixos}/gaming/minecraft-server.nix (100%) rename {nixos => modules/nixos}/gaming/steam.nix (100%) rename {nixos => modules/nixos}/graphical/default.nix (100%) rename {nixos => modules/nixos}/graphical/dmenu.nix (100%) rename {nixos => modules/nixos}/graphical/fonts.nix (100%) rename {nixos => modules/nixos}/graphical/i3.nix (100%) rename {nixos => modules/nixos}/graphical/picom.nix (100%) rename {nixos => modules/nixos}/graphical/polybar.nix (100%) rename {nixos => modules/nixos}/graphical/rofi.nix (100%) rename {nixos => modules/nixos}/graphical/rofi/brightness.sh (100%) rename {nixos => modules/nixos}/graphical/xorg.nix (100%) rename {nixos => modules/nixos}/hardware/audio.nix (100%) rename {nixos => modules/nixos}/hardware/boot.nix (100%) rename {nixos => modules/nixos}/hardware/default.nix (100%) rename {nixos => modules/nixos}/hardware/keyboard.nix (100%) rename {nixos => modules/nixos}/hardware/monitors.nix (100%) rename {nixos => modules/nixos}/hardware/mouse.nix (100%) rename {nixos => modules/nixos}/hardware/networking.nix (100%) rename {nixos => modules/nixos}/hardware/server.nix (100%) rename {nixos => modules/nixos}/hardware/sleep.nix (100%) rename {nixos => modules/nixos}/hardware/wifi.nix (100%) rename {nixos => modules/nixos}/services/backups.nix (100%) rename {nixos => modules/nixos}/services/caddy.nix (100%) rename {nixos => modules/nixos}/services/calibre.nix (100%) rename {nixos => modules/nixos}/services/cloudflare.nix (100%) rename {nixos => modules/nixos}/services/default.nix (100%) rename {nixos => modules/nixos}/services/gitea.nix (100%) rename {nixos => modules/nixos}/services/gnupg.nix (100%) rename {nixos => modules/nixos}/services/honeypot.nix (100%) rename {nixos => modules/nixos}/services/jellyfin.nix (100%) rename {nixos => modules/nixos}/services/keybase.nix (100%) rename {nixos => modules/nixos}/services/mullvad.nix (100%) rename {nixos => modules/nixos}/services/n8n.nix (100%) rename {nixos => modules/nixos}/services/netdata.nix (100%) rename {nixos => modules/nixos}/services/nextcloud.nix (100%) rename {nixos => modules/nixos}/services/prometheus.nix (100%) rename {nixos => modules/nixos}/services/secrets.nix (100%) rename {nixos => modules/nixos}/services/sshd.nix (100%) rename {nixos => modules/nixos}/services/transmission.nix (100%) rename {nixos => modules/nixos}/services/vaultwarden.nix (100%) rename {nixos => modules/nixos}/services/wireguard.nix (100%) rename {nixos => modules/nixos}/system/default.nix (100%) rename {nixos => modules/nixos}/system/doas.nix (100%) rename {nixos => modules/nixos}/system/timezone.nix (100%) rename {nixos => modules/nixos}/system/user.nix (100%) rename {nixos => modules/nixos}/wsl/default.nix (100%) diff --git a/README.md b/README.md index 22a4b42..96a34e5 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ configuration may be difficult to translate to a non-Nix system. However, some of the configurations are easier to lift directly: -- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/neovim/config) -- [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/shell/fish/functions) -- [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/fish/default.nix) -- [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/shell/git.nix) +- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/common/neovim/config) +- [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/common/shell/fish/functions) +- [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/common/shell/fish/default.nix) +- [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/common/shell/git.nix) - [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon) Try out my Neovim config (requires [nix](https://nixos.org/download.html)): diff --git a/apps/default.nix b/apps/default.nix index f4e9064..0d1f1d0 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -57,7 +57,7 @@ neovim = { type = "app"; program = "${ - (import ../modules/neovim/package { + (import ../modules/common/neovim/package { inherit pkgs; colors = import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; }; diff --git a/flake.nix b/flake.nix index 3841029..933868e 100644 --- a/flake.nix +++ b/flake.nix @@ -161,7 +161,7 @@ }; neovim = let pkgs = import nixpkgs { inherit system overlays; }; - in import ./modules/neovim/package { + in import ./modules/common/neovim/package { inherit pkgs; colors = import ./colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; }; diff --git a/generators/aws/default.nix b/generators/aws/default.nix index 036679f..1480cbd 100644 --- a/generators/aws/default.nix +++ b/generators/aws/default.nix @@ -15,16 +15,16 @@ nixos-generators.nixosGenerate { gitEmail = globals.gitEmail; networking.hostName = "sheep"; gui.enable = false; - colorscheme = (import ../modules/colorscheme/gruvbox); + colorscheme = (import ../colorscheme/gruvbox); passwordHash = null; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; # AWS settings require this permitRootLogin = "prohibit-password"; } - ../../hosts/common.nix + ../../modules/common ../../modules/nixos - ../../modules/services/sshd.nix + ../../modules/common/services/sshd.nix ] ++ [ # Required to fix diskSize errors during build ({ ... }: { amazonImage.sizeMB = 16 * 1024; }) diff --git a/hosts/flame/default.nix b/hosts/flame/default.nix index 857f8e8..89db166 100644 --- a/hosts/flame/default.nix +++ b/hosts/flame/default.nix @@ -13,8 +13,8 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix - ../../modules - ../../nixos + ../../modules/common + ../../modules/nixos (removeAttrs globals [ "mail.server" ]) wsl.nixosModules.wsl home-manager.nixosModules.home-manager diff --git a/hosts/hydra/default.nix b/hosts/hydra/default.nix index 63e3273..24006fe 100644 --- a/hosts/hydra/default.nix +++ b/hosts/hydra/default.nix @@ -9,8 +9,8 @@ nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { }; modules = [ - ../../modules - ../../nixos + ../../modules/common + ../../modules/nixos globals wsl.nixosModules.wsl home-manager.nixosModules.home-manager diff --git a/hosts/lookingglass/default.nix b/hosts/lookingglass/default.nix index 3eb9573..3f05927 100644 --- a/hosts/lookingglass/default.nix +++ b/hosts/lookingglass/default.nix @@ -9,8 +9,8 @@ darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs = { }; modules = [ - ../../modules - ../../darwin + ../../modules/common + ../../modules/darwin (globals // { user = "Noah.Masur"; gitName = "Noah-Masur_1701"; diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index fee6e9e..024cdd4 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,8 +10,8 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix - ../../modules - ../../nixos + ../../modules/common + ../../modules/nixos (removeAttrs globals [ "mail.server" ]) wsl.nixosModules.wsl home-manager.nixosModules.home-manager diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix index b6a6ab7..2341e9e 100644 --- a/hosts/tempest/default.nix +++ b/hosts/tempest/default.nix @@ -10,8 +10,8 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix - ../../modules - ../../nixos + ../../modules/common + ../../modules/nixos globals wsl.nixosModules.wsl home-manager.nixosModules.home-manager diff --git a/modules/applications/1password.nix b/modules/common/applications/1password.nix similarity index 100% rename from modules/applications/1password.nix rename to modules/common/applications/1password.nix diff --git a/modules/applications/alacritty.nix b/modules/common/applications/alacritty.nix similarity index 100% rename from modules/applications/alacritty.nix rename to modules/common/applications/alacritty.nix diff --git a/modules/applications/default.nix b/modules/common/applications/default.nix similarity index 100% rename from modules/applications/default.nix rename to modules/common/applications/default.nix diff --git a/modules/applications/discord.nix b/modules/common/applications/discord.nix similarity index 100% rename from modules/applications/discord.nix rename to modules/common/applications/discord.nix diff --git a/modules/applications/firefox.nix b/modules/common/applications/firefox.nix similarity index 100% rename from modules/applications/firefox.nix rename to modules/common/applications/firefox.nix diff --git a/modules/applications/kitty.nix b/modules/common/applications/kitty.nix similarity index 100% rename from modules/applications/kitty.nix rename to modules/common/applications/kitty.nix diff --git a/modules/applications/media.nix b/modules/common/applications/media.nix similarity index 100% rename from modules/applications/media.nix rename to modules/common/applications/media.nix diff --git a/modules/applications/nautilus.nix b/modules/common/applications/nautilus.nix similarity index 100% rename from modules/applications/nautilus.nix rename to modules/common/applications/nautilus.nix diff --git a/modules/applications/obsidian.nix b/modules/common/applications/obsidian.nix similarity index 100% rename from modules/applications/obsidian.nix rename to modules/common/applications/obsidian.nix diff --git a/modules/applications/qbittorrent.nix b/modules/common/applications/qbittorrent.nix similarity index 100% rename from modules/applications/qbittorrent.nix rename to modules/common/applications/qbittorrent.nix diff --git a/modules/default.nix b/modules/common/default.nix similarity index 100% rename from modules/default.nix rename to modules/common/default.nix diff --git a/modules/mail/aerc.nix b/modules/common/mail/aerc.nix similarity index 100% rename from modules/mail/aerc.nix rename to modules/common/mail/aerc.nix diff --git a/modules/mail/default.nix b/modules/common/mail/default.nix similarity index 100% rename from modules/mail/default.nix rename to modules/common/mail/default.nix diff --git a/modules/mail/himalaya.nix b/modules/common/mail/himalaya.nix similarity index 100% rename from modules/mail/himalaya.nix rename to modules/common/mail/himalaya.nix diff --git a/modules/neovim/config/bufferline.nix b/modules/common/neovim/config/bufferline.nix similarity index 100% rename from modules/neovim/config/bufferline.nix rename to modules/common/neovim/config/bufferline.nix diff --git a/modules/neovim/config/completion.nix b/modules/common/neovim/config/completion.nix similarity index 100% rename from modules/neovim/config/completion.nix rename to modules/common/neovim/config/completion.nix diff --git a/modules/neovim/config/gitsigns.lua b/modules/common/neovim/config/gitsigns.lua similarity index 100% rename from modules/neovim/config/gitsigns.lua rename to modules/common/neovim/config/gitsigns.lua diff --git a/modules/neovim/config/gitsigns.nix b/modules/common/neovim/config/gitsigns.nix similarity index 100% rename from modules/neovim/config/gitsigns.nix rename to modules/common/neovim/config/gitsigns.nix diff --git a/modules/neovim/config/lsp.lua b/modules/common/neovim/config/lsp.lua similarity index 100% rename from modules/neovim/config/lsp.lua rename to modules/common/neovim/config/lsp.lua diff --git a/modules/neovim/config/lsp.nix b/modules/common/neovim/config/lsp.nix similarity index 100% rename from modules/neovim/config/lsp.nix rename to modules/common/neovim/config/lsp.nix diff --git a/modules/neovim/config/misc.nix b/modules/common/neovim/config/misc.nix similarity index 100% rename from modules/neovim/config/misc.nix rename to modules/common/neovim/config/misc.nix diff --git a/modules/neovim/config/statusline.nix b/modules/common/neovim/config/statusline.nix similarity index 100% rename from modules/neovim/config/statusline.nix rename to modules/common/neovim/config/statusline.nix diff --git a/modules/neovim/config/syntax.nix b/modules/common/neovim/config/syntax.nix similarity index 100% rename from modules/neovim/config/syntax.nix rename to modules/common/neovim/config/syntax.nix diff --git a/modules/neovim/config/telescope.lua b/modules/common/neovim/config/telescope.lua similarity index 100% rename from modules/neovim/config/telescope.lua rename to modules/common/neovim/config/telescope.lua diff --git a/modules/neovim/config/telescope.nix b/modules/common/neovim/config/telescope.nix similarity index 100% rename from modules/neovim/config/telescope.nix rename to modules/common/neovim/config/telescope.nix diff --git a/modules/neovim/config/toggleterm.lua b/modules/common/neovim/config/toggleterm.lua similarity index 100% rename from modules/neovim/config/toggleterm.lua rename to modules/common/neovim/config/toggleterm.lua diff --git a/modules/neovim/config/toggleterm.nix b/modules/common/neovim/config/toggleterm.nix similarity index 100% rename from modules/neovim/config/toggleterm.nix rename to modules/common/neovim/config/toggleterm.nix diff --git a/modules/neovim/config/tree.nix b/modules/common/neovim/config/tree.nix similarity index 100% rename from modules/neovim/config/tree.nix rename to modules/common/neovim/config/tree.nix diff --git a/modules/neovim/default.nix b/modules/common/neovim/default.nix similarity index 100% rename from modules/neovim/default.nix rename to modules/common/neovim/default.nix diff --git a/modules/neovim/init.lua b/modules/common/neovim/init.lua similarity index 100% rename from modules/neovim/init.lua rename to modules/common/neovim/init.lua diff --git a/modules/neovim/lua/keybinds.lua b/modules/common/neovim/lua/keybinds.lua similarity index 100% rename from modules/neovim/lua/keybinds.lua rename to modules/common/neovim/lua/keybinds.lua diff --git a/modules/neovim/lua/packer/completion.lua b/modules/common/neovim/lua/packer/completion.lua similarity index 100% rename from modules/neovim/lua/packer/completion.lua rename to modules/common/neovim/lua/packer/completion.lua diff --git a/modules/neovim/lua/packer/lsp.lua b/modules/common/neovim/lua/packer/lsp.lua similarity index 100% rename from modules/neovim/lua/packer/lsp.lua rename to modules/common/neovim/lua/packer/lsp.lua diff --git a/modules/neovim/lua/packer/misc.lua b/modules/common/neovim/lua/packer/misc.lua similarity index 100% rename from modules/neovim/lua/packer/misc.lua rename to modules/common/neovim/lua/packer/misc.lua diff --git a/modules/neovim/lua/packer/speed.lua b/modules/common/neovim/lua/packer/speed.lua similarity index 100% rename from modules/neovim/lua/packer/speed.lua rename to modules/common/neovim/lua/packer/speed.lua diff --git a/modules/neovim/lua/packer/syntax.lua b/modules/common/neovim/lua/packer/syntax.lua similarity index 100% rename from modules/neovim/lua/packer/syntax.lua rename to modules/common/neovim/lua/packer/syntax.lua diff --git a/modules/neovim/lua/packer/telescope.lua b/modules/common/neovim/lua/packer/telescope.lua similarity index 100% rename from modules/neovim/lua/packer/telescope.lua rename to modules/common/neovim/lua/packer/telescope.lua diff --git a/modules/neovim/lua/packer/toggleterm.lua b/modules/common/neovim/lua/packer/toggleterm.lua similarity index 100% rename from modules/neovim/lua/packer/toggleterm.lua rename to modules/common/neovim/lua/packer/toggleterm.lua diff --git a/modules/neovim/lua/packer/visuals.lua b/modules/common/neovim/lua/packer/visuals.lua similarity index 100% rename from modules/neovim/lua/packer/visuals.lua rename to modules/common/neovim/lua/packer/visuals.lua diff --git a/modules/neovim/lua/packer_init.lua b/modules/common/neovim/lua/packer_init.lua similarity index 100% rename from modules/neovim/lua/packer_init.lua rename to modules/common/neovim/lua/packer_init.lua diff --git a/modules/neovim/lua/settings.lua b/modules/common/neovim/lua/settings.lua similarity index 100% rename from modules/neovim/lua/settings.lua rename to modules/common/neovim/lua/settings.lua diff --git a/modules/neovim/package/default.nix b/modules/common/neovim/package/default.nix similarity index 59% rename from modules/neovim/package/default.nix rename to modules/common/neovim/package/default.nix index 1e70496..f0991c1 100644 --- a/modules/neovim/package/default.nix +++ b/modules/common/neovim/package/default.nix @@ -13,16 +13,16 @@ # in pkgs.neovimBuilder { # package = pkgs.neovim-unwrapped; # imports = [ -# ./modules/neovim/plugins/bufferline.nix -# ./modules/neovim/plugins/completion.nix -# ./modules/neovim/plugins/gitsigns.nix -# ./modules/neovim/plugins/lsp.nix -# ./modules/neovim/plugins/misc.nix -# ./modules/neovim/plugins/statusline.nix -# ./modules/neovim/plugins/syntax.nix -# ./modules/neovim/plugins/telescope.nix -# ./modules/neovim/plugins/toggleterm.nix -# ./modules/neovim/plugins/tree.nix +# ./modules/common/neovim/plugins/bufferline.nix +# ./modules/common/neovim/plugins/completion.nix +# ./modules/common/neovim/plugins/gitsigns.nix +# ./modules/common/neovim/plugins/lsp.nix +# ./modules/common/neovim/plugins/misc.nix +# ./modules/common/neovim/plugins/statusline.nix +# ./modules/common/neovim/plugins/syntax.nix +# ./modules/common/neovim/plugins/telescope.nix +# ./modules/common/neovim/plugins/toggleterm.nix +# ./modules/common/neovim/plugins/tree.nix # ] ++ extraConfig; # } diff --git a/modules/programming/default.nix b/modules/common/programming/default.nix similarity index 100% rename from modules/programming/default.nix rename to modules/common/programming/default.nix diff --git a/modules/programming/haskell.nix b/modules/common/programming/haskell.nix similarity index 100% rename from modules/programming/haskell.nix rename to modules/common/programming/haskell.nix diff --git a/modules/programming/kubernetes.nix b/modules/common/programming/kubernetes.nix similarity index 100% rename from modules/programming/kubernetes.nix rename to modules/common/programming/kubernetes.nix diff --git a/modules/programming/lua.nix b/modules/common/programming/lua.nix similarity index 100% rename from modules/programming/lua.nix rename to modules/common/programming/lua.nix diff --git a/modules/programming/nix.nix b/modules/common/programming/nix.nix similarity index 100% rename from modules/programming/nix.nix rename to modules/common/programming/nix.nix diff --git a/modules/programming/python.nix b/modules/common/programming/python.nix similarity index 100% rename from modules/programming/python.nix rename to modules/common/programming/python.nix diff --git a/modules/programming/terraform.nix b/modules/common/programming/terraform.nix similarity index 100% rename from modules/programming/terraform.nix rename to modules/common/programming/terraform.nix diff --git a/modules/repositories/default.nix b/modules/common/repositories/default.nix similarity index 100% rename from modules/repositories/default.nix rename to modules/common/repositories/default.nix diff --git a/modules/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix similarity index 100% rename from modules/repositories/dotfiles.nix rename to modules/common/repositories/dotfiles.nix diff --git a/modules/repositories/notes.nix b/modules/common/repositories/notes.nix similarity index 100% rename from modules/repositories/notes.nix rename to modules/common/repositories/notes.nix diff --git a/modules/shell/bash/scripts/ocr.sh b/modules/common/shell/bash/scripts/ocr.sh similarity index 100% rename from modules/shell/bash/scripts/ocr.sh rename to modules/common/shell/bash/scripts/ocr.sh diff --git a/modules/shell/charm.nix b/modules/common/shell/charm.nix similarity index 100% rename from modules/shell/charm.nix rename to modules/common/shell/charm.nix diff --git a/modules/shell/default.nix b/modules/common/shell/default.nix similarity index 100% rename from modules/shell/default.nix rename to modules/common/shell/default.nix diff --git a/modules/shell/direnv.nix b/modules/common/shell/direnv.nix similarity index 100% rename from modules/shell/direnv.nix rename to modules/common/shell/direnv.nix diff --git a/modules/shell/fish/default.nix b/modules/common/shell/fish/default.nix similarity index 100% rename from modules/shell/fish/default.nix rename to modules/common/shell/fish/default.nix diff --git a/modules/shell/fish/functions/commandline-git-commits.fish b/modules/common/shell/fish/functions/commandline-git-commits.fish similarity index 100% rename from modules/shell/fish/functions/commandline-git-commits.fish rename to modules/common/shell/fish/functions/commandline-git-commits.fish diff --git a/modules/shell/fish/functions/edit.fish b/modules/common/shell/fish/functions/edit.fish similarity index 100% rename from modules/shell/fish/functions/edit.fish rename to modules/common/shell/fish/functions/edit.fish diff --git a/modules/shell/fish/functions/fcd.fish b/modules/common/shell/fish/functions/fcd.fish similarity index 100% rename from modules/shell/fish/functions/fcd.fish rename to modules/common/shell/fish/functions/fcd.fish diff --git a/modules/shell/fish/functions/fish_user_key_bindings.fish b/modules/common/shell/fish/functions/fish_user_key_bindings.fish similarity index 100% rename from modules/shell/fish/functions/fish_user_key_bindings.fish rename to modules/common/shell/fish/functions/fish_user_key_bindings.fish diff --git a/modules/shell/fish/functions/fish_vi_cursor.fish b/modules/common/shell/fish/functions/fish_vi_cursor.fish similarity index 100% rename from modules/shell/fish/functions/fish_vi_cursor.fish rename to modules/common/shell/fish/functions/fish_vi_cursor.fish diff --git a/modules/shell/fish/functions/git-add-fuzzy.fish b/modules/common/shell/fish/functions/git-add-fuzzy.fish similarity index 100% rename from modules/shell/fish/functions/git-add-fuzzy.fish rename to modules/common/shell/fish/functions/git-add-fuzzy.fish diff --git a/modules/shell/fish/functions/git-commits.fish b/modules/common/shell/fish/functions/git-commits.fish similarity index 100% rename from modules/shell/fish/functions/git-commits.fish rename to modules/common/shell/fish/functions/git-commits.fish diff --git a/modules/shell/fish/functions/git-fuzzy-branch.fish b/modules/common/shell/fish/functions/git-fuzzy-branch.fish similarity index 100% rename from modules/shell/fish/functions/git-fuzzy-branch.fish rename to modules/common/shell/fish/functions/git-fuzzy-branch.fish diff --git a/modules/shell/fish/functions/git-history.fish b/modules/common/shell/fish/functions/git-history.fish similarity index 100% rename from modules/shell/fish/functions/git-history.fish rename to modules/common/shell/fish/functions/git-history.fish diff --git a/modules/shell/fish/functions/git-push-upstream.fish b/modules/common/shell/fish/functions/git-push-upstream.fish similarity index 100% rename from modules/shell/fish/functions/git-push-upstream.fish rename to modules/common/shell/fish/functions/git-push-upstream.fish diff --git a/modules/shell/fish/functions/git-show-fuzzy.fish b/modules/common/shell/fish/functions/git-show-fuzzy.fish similarity index 100% rename from modules/shell/fish/functions/git-show-fuzzy.fish rename to modules/common/shell/fish/functions/git-show-fuzzy.fish diff --git a/modules/shell/fish/functions/git.fish b/modules/common/shell/fish/functions/git.fish similarity index 100% rename from modules/shell/fish/functions/git.fish rename to modules/common/shell/fish/functions/git.fish diff --git a/modules/shell/fish/functions/ip.fish b/modules/common/shell/fish/functions/ip.fish similarity index 100% rename from modules/shell/fish/functions/ip.fish rename to modules/common/shell/fish/functions/ip.fish diff --git a/modules/shell/fish/functions/note.fish b/modules/common/shell/fish/functions/note.fish similarity index 100% rename from modules/shell/fish/functions/note.fish rename to modules/common/shell/fish/functions/note.fish diff --git a/modules/shell/fish/functions/recent.fish b/modules/common/shell/fish/functions/recent.fish similarity index 100% rename from modules/shell/fish/functions/recent.fish rename to modules/common/shell/fish/functions/recent.fish diff --git a/modules/shell/fish/functions/search-and-edit.fish b/modules/common/shell/fish/functions/search-and-edit.fish similarity index 100% rename from modules/shell/fish/functions/search-and-edit.fish rename to modules/common/shell/fish/functions/search-and-edit.fish diff --git a/modules/shell/fish/functions/syncnotes.fish b/modules/common/shell/fish/functions/syncnotes.fish similarity index 100% rename from modules/shell/fish/functions/syncnotes.fish rename to modules/common/shell/fish/functions/syncnotes.fish diff --git a/modules/shell/fish/functions/uncommitted.fish b/modules/common/shell/fish/functions/uncommitted.fish similarity index 100% rename from modules/shell/fish/functions/uncommitted.fish rename to modules/common/shell/fish/functions/uncommitted.fish diff --git a/modules/shell/fzf.nix b/modules/common/shell/fzf.nix similarity index 100% rename from modules/shell/fzf.nix rename to modules/common/shell/fzf.nix diff --git a/modules/shell/git.nix b/modules/common/shell/git.nix similarity index 100% rename from modules/shell/git.nix rename to modules/common/shell/git.nix diff --git a/modules/shell/github.nix b/modules/common/shell/github.nix similarity index 100% rename from modules/shell/github.nix rename to modules/common/shell/github.nix diff --git a/modules/shell/nixpkgs.nix b/modules/common/shell/nixpkgs.nix similarity index 100% rename from modules/shell/nixpkgs.nix rename to modules/common/shell/nixpkgs.nix diff --git a/modules/shell/starship.nix b/modules/common/shell/starship.nix similarity index 100% rename from modules/shell/starship.nix rename to modules/common/shell/starship.nix diff --git a/modules/shell/utilities.nix b/modules/common/shell/utilities.nix similarity index 100% rename from modules/shell/utilities.nix rename to modules/common/shell/utilities.nix diff --git a/darwin/alacritty.nix b/modules/darwin/alacritty.nix similarity index 100% rename from darwin/alacritty.nix rename to modules/darwin/alacritty.nix diff --git a/darwin/default.nix b/modules/darwin/default.nix similarity index 100% rename from darwin/default.nix rename to modules/darwin/default.nix diff --git a/darwin/fonts.nix b/modules/darwin/fonts.nix similarity index 100% rename from darwin/fonts.nix rename to modules/darwin/fonts.nix diff --git a/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix similarity index 100% rename from darwin/hammerspoon.nix rename to modules/darwin/hammerspoon.nix diff --git a/darwin/hammerspoon/.stylua.toml b/modules/darwin/hammerspoon/.stylua.toml similarity index 100% rename from darwin/hammerspoon/.stylua.toml rename to modules/darwin/hammerspoon/.stylua.toml diff --git a/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua similarity index 100% rename from darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua rename to modules/darwin/hammerspoon/Spoons/ControlEscape.spoon/init.lua diff --git a/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js similarity index 100% rename from darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js rename to modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications_applescript.js diff --git a/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua similarity index 100% rename from darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua rename to modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua diff --git a/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua similarity index 100% rename from darwin/hammerspoon/Spoons/Launcher.spoon/init.lua rename to modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua diff --git a/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua similarity index 100% rename from darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua rename to modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/init.lua diff --git a/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua b/modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua similarity index 100% rename from darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua rename to modules/darwin/hammerspoon/Spoons/MoveWindow.spoon/worklayout.lua diff --git a/darwin/hammerspoon/init.lua b/modules/darwin/hammerspoon/init.lua similarity index 100% rename from darwin/hammerspoon/init.lua rename to modules/darwin/hammerspoon/init.lua diff --git a/darwin/homebrew.nix b/modules/darwin/homebrew.nix similarity index 100% rename from darwin/homebrew.nix rename to modules/darwin/homebrew.nix diff --git a/darwin/kitty.nix b/modules/darwin/kitty.nix similarity index 100% rename from darwin/kitty.nix rename to modules/darwin/kitty.nix diff --git a/darwin/networking.nix b/modules/darwin/networking.nix similarity index 100% rename from darwin/networking.nix rename to modules/darwin/networking.nix diff --git a/darwin/nixpkgs.nix b/modules/darwin/nixpkgs.nix similarity index 100% rename from darwin/nixpkgs.nix rename to modules/darwin/nixpkgs.nix diff --git a/darwin/system.nix b/modules/darwin/system.nix similarity index 100% rename from darwin/system.nix rename to modules/darwin/system.nix diff --git a/darwin/tmux.nix b/modules/darwin/tmux.nix similarity index 100% rename from darwin/tmux.nix rename to modules/darwin/tmux.nix diff --git a/darwin/user.nix b/modules/darwin/user.nix similarity index 100% rename from darwin/user.nix rename to modules/darwin/user.nix diff --git a/darwin/utilities.nix b/modules/darwin/utilities.nix similarity index 95% rename from darwin/utilities.nix rename to modules/darwin/utilities.nix index 5f65a35..763dba7 100644 --- a/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -34,7 +34,7 @@ in { ipcalc # Make IP network calculations (mkScript { name = "ocr"; - file = ../modules/shell/bash/scripts/ocr.sh; + file = ../../modules/common/shell/bash/scripts/ocr.sh; env = [ tesseract ]; }) ]; diff --git a/nixos/applications/calibre.nix b/modules/nixos/applications/calibre.nix similarity index 100% rename from nixos/applications/calibre.nix rename to modules/nixos/applications/calibre.nix diff --git a/nixos/applications/default.nix b/modules/nixos/applications/default.nix similarity index 100% rename from nixos/applications/default.nix rename to modules/nixos/applications/default.nix diff --git a/nixos/default.nix b/modules/nixos/default.nix similarity index 100% rename from nixos/default.nix rename to modules/nixos/default.nix diff --git a/nixos/gaming/default.nix b/modules/nixos/gaming/default.nix similarity index 100% rename from nixos/gaming/default.nix rename to modules/nixos/gaming/default.nix diff --git a/nixos/gaming/leagueoflegends.nix b/modules/nixos/gaming/leagueoflegends.nix similarity index 100% rename from nixos/gaming/leagueoflegends.nix rename to modules/nixos/gaming/leagueoflegends.nix diff --git a/nixos/gaming/legendary.nix b/modules/nixos/gaming/legendary.nix similarity index 100% rename from nixos/gaming/legendary.nix rename to modules/nixos/gaming/legendary.nix diff --git a/nixos/gaming/lutris.nix b/modules/nixos/gaming/lutris.nix similarity index 100% rename from nixos/gaming/lutris.nix rename to modules/nixos/gaming/lutris.nix diff --git a/nixos/gaming/minecraft-server.nix b/modules/nixos/gaming/minecraft-server.nix similarity index 100% rename from nixos/gaming/minecraft-server.nix rename to modules/nixos/gaming/minecraft-server.nix diff --git a/nixos/gaming/steam.nix b/modules/nixos/gaming/steam.nix similarity index 100% rename from nixos/gaming/steam.nix rename to modules/nixos/gaming/steam.nix diff --git a/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix similarity index 100% rename from nixos/graphical/default.nix rename to modules/nixos/graphical/default.nix diff --git a/nixos/graphical/dmenu.nix b/modules/nixos/graphical/dmenu.nix similarity index 100% rename from nixos/graphical/dmenu.nix rename to modules/nixos/graphical/dmenu.nix diff --git a/nixos/graphical/fonts.nix b/modules/nixos/graphical/fonts.nix similarity index 100% rename from nixos/graphical/fonts.nix rename to modules/nixos/graphical/fonts.nix diff --git a/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix similarity index 100% rename from nixos/graphical/i3.nix rename to modules/nixos/graphical/i3.nix diff --git a/nixos/graphical/picom.nix b/modules/nixos/graphical/picom.nix similarity index 100% rename from nixos/graphical/picom.nix rename to modules/nixos/graphical/picom.nix diff --git a/nixos/graphical/polybar.nix b/modules/nixos/graphical/polybar.nix similarity index 100% rename from nixos/graphical/polybar.nix rename to modules/nixos/graphical/polybar.nix diff --git a/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix similarity index 100% rename from nixos/graphical/rofi.nix rename to modules/nixos/graphical/rofi.nix diff --git a/nixos/graphical/rofi/brightness.sh b/modules/nixos/graphical/rofi/brightness.sh similarity index 100% rename from nixos/graphical/rofi/brightness.sh rename to modules/nixos/graphical/rofi/brightness.sh diff --git a/nixos/graphical/xorg.nix b/modules/nixos/graphical/xorg.nix similarity index 100% rename from nixos/graphical/xorg.nix rename to modules/nixos/graphical/xorg.nix diff --git a/nixos/hardware/audio.nix b/modules/nixos/hardware/audio.nix similarity index 100% rename from nixos/hardware/audio.nix rename to modules/nixos/hardware/audio.nix diff --git a/nixos/hardware/boot.nix b/modules/nixos/hardware/boot.nix similarity index 100% rename from nixos/hardware/boot.nix rename to modules/nixos/hardware/boot.nix diff --git a/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix similarity index 100% rename from nixos/hardware/default.nix rename to modules/nixos/hardware/default.nix diff --git a/nixos/hardware/keyboard.nix b/modules/nixos/hardware/keyboard.nix similarity index 100% rename from nixos/hardware/keyboard.nix rename to modules/nixos/hardware/keyboard.nix diff --git a/nixos/hardware/monitors.nix b/modules/nixos/hardware/monitors.nix similarity index 100% rename from nixos/hardware/monitors.nix rename to modules/nixos/hardware/monitors.nix diff --git a/nixos/hardware/mouse.nix b/modules/nixos/hardware/mouse.nix similarity index 100% rename from nixos/hardware/mouse.nix rename to modules/nixos/hardware/mouse.nix diff --git a/nixos/hardware/networking.nix b/modules/nixos/hardware/networking.nix similarity index 100% rename from nixos/hardware/networking.nix rename to modules/nixos/hardware/networking.nix diff --git a/nixos/hardware/server.nix b/modules/nixos/hardware/server.nix similarity index 100% rename from nixos/hardware/server.nix rename to modules/nixos/hardware/server.nix diff --git a/nixos/hardware/sleep.nix b/modules/nixos/hardware/sleep.nix similarity index 100% rename from nixos/hardware/sleep.nix rename to modules/nixos/hardware/sleep.nix diff --git a/nixos/hardware/wifi.nix b/modules/nixos/hardware/wifi.nix similarity index 100% rename from nixos/hardware/wifi.nix rename to modules/nixos/hardware/wifi.nix diff --git a/nixos/services/backups.nix b/modules/nixos/services/backups.nix similarity index 100% rename from nixos/services/backups.nix rename to modules/nixos/services/backups.nix diff --git a/nixos/services/caddy.nix b/modules/nixos/services/caddy.nix similarity index 100% rename from nixos/services/caddy.nix rename to modules/nixos/services/caddy.nix diff --git a/nixos/services/calibre.nix b/modules/nixos/services/calibre.nix similarity index 100% rename from nixos/services/calibre.nix rename to modules/nixos/services/calibre.nix diff --git a/nixos/services/cloudflare.nix b/modules/nixos/services/cloudflare.nix similarity index 100% rename from nixos/services/cloudflare.nix rename to modules/nixos/services/cloudflare.nix diff --git a/nixos/services/default.nix b/modules/nixos/services/default.nix similarity index 100% rename from nixos/services/default.nix rename to modules/nixos/services/default.nix diff --git a/nixos/services/gitea.nix b/modules/nixos/services/gitea.nix similarity index 100% rename from nixos/services/gitea.nix rename to modules/nixos/services/gitea.nix diff --git a/nixos/services/gnupg.nix b/modules/nixos/services/gnupg.nix similarity index 100% rename from nixos/services/gnupg.nix rename to modules/nixos/services/gnupg.nix diff --git a/nixos/services/honeypot.nix b/modules/nixos/services/honeypot.nix similarity index 100% rename from nixos/services/honeypot.nix rename to modules/nixos/services/honeypot.nix diff --git a/nixos/services/jellyfin.nix b/modules/nixos/services/jellyfin.nix similarity index 100% rename from nixos/services/jellyfin.nix rename to modules/nixos/services/jellyfin.nix diff --git a/nixos/services/keybase.nix b/modules/nixos/services/keybase.nix similarity index 100% rename from nixos/services/keybase.nix rename to modules/nixos/services/keybase.nix diff --git a/nixos/services/mullvad.nix b/modules/nixos/services/mullvad.nix similarity index 100% rename from nixos/services/mullvad.nix rename to modules/nixos/services/mullvad.nix diff --git a/nixos/services/n8n.nix b/modules/nixos/services/n8n.nix similarity index 100% rename from nixos/services/n8n.nix rename to modules/nixos/services/n8n.nix diff --git a/nixos/services/netdata.nix b/modules/nixos/services/netdata.nix similarity index 100% rename from nixos/services/netdata.nix rename to modules/nixos/services/netdata.nix diff --git a/nixos/services/nextcloud.nix b/modules/nixos/services/nextcloud.nix similarity index 100% rename from nixos/services/nextcloud.nix rename to modules/nixos/services/nextcloud.nix diff --git a/nixos/services/prometheus.nix b/modules/nixos/services/prometheus.nix similarity index 100% rename from nixos/services/prometheus.nix rename to modules/nixos/services/prometheus.nix diff --git a/nixos/services/secrets.nix b/modules/nixos/services/secrets.nix similarity index 100% rename from nixos/services/secrets.nix rename to modules/nixos/services/secrets.nix diff --git a/nixos/services/sshd.nix b/modules/nixos/services/sshd.nix similarity index 100% rename from nixos/services/sshd.nix rename to modules/nixos/services/sshd.nix diff --git a/nixos/services/transmission.nix b/modules/nixos/services/transmission.nix similarity index 100% rename from nixos/services/transmission.nix rename to modules/nixos/services/transmission.nix diff --git a/nixos/services/vaultwarden.nix b/modules/nixos/services/vaultwarden.nix similarity index 100% rename from nixos/services/vaultwarden.nix rename to modules/nixos/services/vaultwarden.nix diff --git a/nixos/services/wireguard.nix b/modules/nixos/services/wireguard.nix similarity index 100% rename from nixos/services/wireguard.nix rename to modules/nixos/services/wireguard.nix diff --git a/nixos/system/default.nix b/modules/nixos/system/default.nix similarity index 100% rename from nixos/system/default.nix rename to modules/nixos/system/default.nix diff --git a/nixos/system/doas.nix b/modules/nixos/system/doas.nix similarity index 100% rename from nixos/system/doas.nix rename to modules/nixos/system/doas.nix diff --git a/nixos/system/timezone.nix b/modules/nixos/system/timezone.nix similarity index 100% rename from nixos/system/timezone.nix rename to modules/nixos/system/timezone.nix diff --git a/nixos/system/user.nix b/modules/nixos/system/user.nix similarity index 100% rename from nixos/system/user.nix rename to modules/nixos/system/user.nix diff --git a/nixos/wsl/default.nix b/modules/nixos/wsl/default.nix similarity index 100% rename from nixos/wsl/default.nix rename to modules/nixos/wsl/default.nix From 450118d234daa43497dc7615b6cdc3f9f4517c4e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:45:56 -0500 Subject: [PATCH 190/391] remove dead code with deadnix --- flake.nix | 2 +- generators/staff/default.nix | 2 +- hosts/flame/hardware-configuration.nix | 2 +- hosts/tempest/hardware-configuration.nix | 2 +- modules/common/neovim/config/syntax.nix | 2 +- modules/common/programming/default.nix | 2 +- modules/common/programming/haskell.nix | 2 +- modules/common/shell/fish/default.nix | 2 +- modules/common/shell/nixpkgs.nix | 2 +- modules/common/shell/utilities.nix | 4 ++-- modules/darwin/default.nix | 2 +- modules/nixos/services/backups.nix | 2 +- modules/nixos/services/n8n.nix | 2 +- modules/nixos/services/netdata.nix | 2 +- modules/nixos/services/prometheus.nix | 2 +- overlays/calibre-web.nix | 2 +- overlays/neovim-plugins.nix | 14 +++++++------- templates/basic/flake.nix | 2 +- templates/haskell/flake.nix | 2 +- templates/poetry/flake.nix | 2 +- templates/python/flake.nix | 4 ++-- 21 files changed, 29 insertions(+), 29 deletions(-) diff --git a/flake.nix b/flake.nix index 933868e..55c564c 100644 --- a/flake.nix +++ b/flake.nix @@ -94,7 +94,7 @@ }; - outputs = { self, nixpkgs, ... }@inputs: + outputs = { nixpkgs, ... }@inputs: let diff --git a/generators/staff/default.nix b/generators/staff/default.nix index 2f225b2..6d4fe0a 100644 --- a/generators/staff/default.nix +++ b/generators/staff/default.nix @@ -1,7 +1,7 @@ # The Staff # ISO configuration for my USB drive -{ inputs, globals, system, overlays, ... }: +{ inputs, system, ... }: with inputs; diff --git a/hosts/flame/hardware-configuration.nix b/hosts/flame/hardware-configuration.nix index ef1e850..e8347f5 100644 --- a/hosts/flame/hardware-configuration.nix +++ b/hosts/flame/hardware-configuration.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ lib, modulesPath, ... }: { imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; diff --git a/hosts/tempest/hardware-configuration.nix b/hosts/tempest/hardware-configuration.nix index bf692e8..113ff46 100644 --- a/hosts/tempest/hardware-configuration.nix +++ b/hosts/tempest/hardware-configuration.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; diff --git a/modules/common/neovim/config/syntax.nix b/modules/common/neovim/config/syntax.nix index 0f223e5..56b8529 100644 --- a/modules/common/neovim/config/syntax.nix +++ b/modules/common/neovim/config/syntax.nix @@ -1,7 +1,7 @@ { pkgs, ... }: { plugins = [ - (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: + (pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins: with pkgs.tree-sitter-grammars; [ tree-sitter-hcl tree-sitter-python diff --git a/modules/common/programming/default.nix b/modules/common/programming/default.nix index 9650fc7..f8e9f5d 100644 --- a/modules/common/programming/default.nix +++ b/modules/common/programming/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ ... }: { imports = [ ./haskell.nix diff --git a/modules/common/programming/haskell.nix b/modules/common/programming/haskell.nix index 7bf3df7..203a7c0 100644 --- a/modules/common/programming/haskell.nix +++ b/modules/common/programming/haskell.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options.haskell.enable = lib.mkEnableOption "Haskell programming language."; diff --git a/modules/common/shell/fish/default.nix b/modules/common/shell/fish/default.nix index 55e00e0..c9f6d22 100644 --- a/modules/common/shell/fish/default.nix +++ b/modules/common/shell/fish/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, ... }: { users.users.${config.user}.shell = pkgs.fish; programs.fish.enable = diff --git a/modules/common/shell/nixpkgs.nix b/modules/common/shell/nixpkgs.nix index 0a8358c..2534d55 100644 --- a/modules/common/shell/nixpkgs.nix +++ b/modules/common/shell/nixpkgs.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, ... }: { home-manager.users.${config.user} = { programs.fish = { diff --git a/modules/common/shell/utilities.nix b/modules/common/shell/utilities.nix index 53a59ef..38aca7d 100644 --- a/modules/common/shell/utilities.nix +++ b/modules/common/shell/utilities.nix @@ -19,8 +19,8 @@ in { # Fix: age won't build nixpkgs.overlays = [ - (final: prev: { - age = prev.age.overrideAttrs (old: { + (_final: prev: { + age = prev.age.overrideAttrs (_old: { src = prev.fetchFromGitHub { owner = "FiloSottile"; repo = "age"; diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 3ce9ed2..1db4a11 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,4 +1,4 @@ -{ config, ... }: { +{ ... }: { imports = [ ./alacritty.nix diff --git a/modules/nixos/services/backups.nix b/modules/nixos/services/backups.nix index c1e143b..026325d 100644 --- a/modules/nixos/services/backups.nix +++ b/modules/nixos/services/backups.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options = { diff --git a/modules/nixos/services/n8n.nix b/modules/nixos/services/n8n.nix index e61096d..1b1c3d4 100644 --- a/modules/nixos/services/n8n.nix +++ b/modules/nixos/services/n8n.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options = { n8nServer = lib.mkOption { diff --git a/modules/nixos/services/netdata.nix b/modules/nixos/services/netdata.nix index 5082c4c..5911c89 100644 --- a/modules/nixos/services/netdata.nix +++ b/modules/nixos/services/netdata.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options.netdata.enable = lib.mkEnableOption "Netdata metrics."; diff --git a/modules/nixos/services/prometheus.nix b/modules/nixos/services/prometheus.nix index b372cca..914d824 100644 --- a/modules/nixos/services/prometheus.nix +++ b/modules/nixos/services/prometheus.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options.metricsServer = lib.mkOption { type = lib.types.nullOr lib.types.str; diff --git a/overlays/calibre-web.nix b/overlays/calibre-web.nix index 6717ec4..3f8e172 100644 --- a/overlays/calibre-web.nix +++ b/overlays/calibre-web.nix @@ -1,6 +1,6 @@ # Fix: https://github.com/janeczku/calibre-web/issues/2422 -final: prev: { +_final: prev: { calibre-web = prev.calibre-web.overrideAttrs (old: { patches = (old.patches or [ ]) ++ [ ./calibre-web-cloudflare.patch ]; }); diff --git a/overlays/neovim-plugins.nix b/overlays/neovim-plugins.nix index a08dd2a..9941492 100644 --- a/overlays/neovim-plugins.nix +++ b/overlays/neovim-plugins.nix @@ -1,18 +1,18 @@ # Adopted from here: https://github.com/DieracDelta/vimconfig/blob/801b62dd56cfee59574639904a6c95b525725f66/plugins.nix -inputs: final: prev: +inputs: _final: prev: let # Use nixpkgs vimPlugin but with source directly from plugin author withSrc = pkg: src: pkg.overrideAttrs (_: { inherit src; }); - # Package plugin - plugin = pname: src: - prev.vimUtils.buildVimPluginFrom2Nix { - inherit pname src; - version = "master"; - }; + # Package plugin - disabling until in use + # plugin = pname: src: + # prev.vimUtils.buildVimPluginFrom2Nix { + # inherit pname src; + # version = "master"; + # }; in { diff --git a/templates/basic/flake.nix b/templates/basic/flake.nix index edfb050..dadd0fb 100644 --- a/templates/basic/flake.nix +++ b/templates/basic/flake.nix @@ -1,7 +1,7 @@ { description = "Basic project"; inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - outputs = { self, nixpkgs }: + outputs = { nixpkgs }: let forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" diff --git a/templates/haskell/flake.nix b/templates/haskell/flake.nix index f6eb37e..f9c6904 100644 --- a/templates/haskell/flake.nix +++ b/templates/haskell/flake.nix @@ -8,7 +8,7 @@ inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, flake-utils, haskellNix }: + outputs = { nixpkgs, flake-utils, haskellNix }: flake-utils.lib.eachDefaultSystem (system: let overlay = self: _: { diff --git a/templates/poetry/flake.nix b/templates/poetry/flake.nix index 10f1e5f..c03832c 100644 --- a/templates/poetry/flake.nix +++ b/templates/poetry/flake.nix @@ -5,7 +5,7 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs"; inputs.poetry2nix.url = "github:nix-community/poetry2nix"; - outputs = { self, nixpkgs, flake-utils, poetry2nix }: + outputs = { nixpkgs, flake-utils, poetry2nix }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { diff --git a/templates/python/flake.nix b/templates/python/flake.nix index 3e4e7cf..ca6e685 100644 --- a/templates/python/flake.nix +++ b/templates/python/flake.nix @@ -3,14 +3,14 @@ inputs.mach-nix.url = "github:DavHau/mach-nix/3.5.0"; - outputs = { self, nixpkgs, mach-nix }@inp: + outputs = { nixpkgs, mach-nix }: let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system (import nixpkgs { inherit system; })); in rec { - defaultApp = forAllSystems (system: pkgs: + defaultApp = forAllSystems (system: _pkgs: mach-nix.lib."${system}".mkPython { requirements = builtins.readFile ./requirements.txt; }); From a8d1369c49b08c27cb17dff1d4574d105eb1ef29 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Feb 2023 22:34:16 -0500 Subject: [PATCH 191/391] remove legacy scripts and configs --- legacy/bin/biggest | 4 - legacy/bin/biggest-files | 3 - legacy/bin/docker_cleanup | 26 --- legacy/bin/jira-checkout | 37 ---- legacy/bin/jira-details | 38 ---- legacy/bin/kube-dashboard | 14 -- legacy/bin/newest | 3 - legacy/bin/oldest | 3 - legacy/bin/pod | 16 -- legacy/bin/symlinks | 3 - legacy/bin/url-decode | 5 - legacy/newsboat/com.noah.newsboat.plist | 28 --- legacy/newsboat/config | 40 ----- legacy/nix-env.fish | 137 -------------- legacy/scripts/configure_macos | 168 ------------------ legacy/scripts/npm | 5 - legacy/scripts/rust | 48 ----- legacy/scripts/setup_cheatsheet | 6 - legacy/scripts/setup_fish | 46 ----- legacy/scripts/setup_ytfzf | 7 - legacy/templates/kubernetes/clusterrole.yaml | 8 - .../kubernetes/clusterrolebinding.yaml | 12 -- legacy/templates/kubernetes/configmap.yaml | 8 - legacy/templates/kubernetes/deployment.yaml | 33 ---- legacy/templates/kubernetes/ingress.yaml | 21 --- legacy/templates/kubernetes/role.yaml | 10 -- legacy/templates/kubernetes/rolebinding.yaml | 13 -- legacy/templates/kubernetes/secret.yaml | 8 - legacy/templates/kubernetes/service.yaml | 15 -- .../templates/kubernetes/serviceaccount.yaml | 5 - legacy/templates/programs/skeleton.py | 12 -- legacy/templates/programs/skeleton.sh | 8 - 32 files changed, 790 deletions(-) delete mode 100755 legacy/bin/biggest delete mode 100755 legacy/bin/biggest-files delete mode 100755 legacy/bin/docker_cleanup delete mode 100755 legacy/bin/jira-checkout delete mode 100755 legacy/bin/jira-details delete mode 100755 legacy/bin/kube-dashboard delete mode 100755 legacy/bin/newest delete mode 100755 legacy/bin/oldest delete mode 100755 legacy/bin/pod delete mode 100755 legacy/bin/symlinks delete mode 100755 legacy/bin/url-decode delete mode 100644 legacy/newsboat/com.noah.newsboat.plist delete mode 100644 legacy/newsboat/config delete mode 100644 legacy/nix-env.fish delete mode 100755 legacy/scripts/configure_macos delete mode 100755 legacy/scripts/npm delete mode 100755 legacy/scripts/rust delete mode 100755 legacy/scripts/setup_cheatsheet delete mode 100755 legacy/scripts/setup_fish delete mode 100755 legacy/scripts/setup_ytfzf delete mode 100644 legacy/templates/kubernetes/clusterrole.yaml delete mode 100644 legacy/templates/kubernetes/clusterrolebinding.yaml delete mode 100644 legacy/templates/kubernetes/configmap.yaml delete mode 100644 legacy/templates/kubernetes/deployment.yaml delete mode 100644 legacy/templates/kubernetes/ingress.yaml delete mode 100644 legacy/templates/kubernetes/role.yaml delete mode 100644 legacy/templates/kubernetes/rolebinding.yaml delete mode 100644 legacy/templates/kubernetes/secret.yaml delete mode 100644 legacy/templates/kubernetes/service.yaml delete mode 100644 legacy/templates/kubernetes/serviceaccount.yaml delete mode 100644 legacy/templates/programs/skeleton.py delete mode 100644 legacy/templates/programs/skeleton.sh diff --git a/legacy/bin/biggest b/legacy/bin/biggest deleted file mode 100755 index 1655ef3..0000000 --- a/legacy/bin/biggest +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/local/bin/nu - -ls | sort-by size | reverse | keep 10 - diff --git a/legacy/bin/biggest-files b/legacy/bin/biggest-files deleted file mode 100755 index 16d10aa..0000000 --- a/legacy/bin/biggest-files +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls **/* | where type == File | sort-by size | reverse | keep 10 diff --git a/legacy/bin/docker_cleanup b/legacy/bin/docker_cleanup deleted file mode 100755 index 59cf41d..0000000 --- a/legacy/bin/docker_cleanup +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -# Stop all containers -if [ "$(docker ps -a -q)" ]; then - echo "Stopping docker containers..." - docker stop "$(docker ps -a -q)" -else - echo "No running docker containers." -fi - -# Remove all stopped containers -if [ "$(docker ps -a -q)" ]; then - echo "Removing docker containers..." - docker rm "$(docker ps -a -q)" -else - echo "No stopped docker containers." -fi - -# Remove all untagged images -if [[ $(docker images | grep "^") ]]; then - docker rmi "$(docker images | grep "^" | awk '{print $3}')" -else - echo "No untagged docker images." -fi - -echo "Cleaned up docker." diff --git a/legacy/bin/jira-checkout b/legacy/bin/jira-checkout deleted file mode 100755 index 69e297c..0000000 --- a/legacy/bin/jira-checkout +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/ -# Requires the following variables to be set: -# - ATLASSIAN_EMAIL -# - ATLASSIAN_API_TOKEN -# - JIRA_HOSTNAME -# - JIRA_PROJECT - -choose_issue() { - jq_template='"\(.key): \(.fields.summary)"' - query="project=$JIRA_PROJECT AND status not in (\"Done\") AND assignee=currentUser()" - - branch_name=$( - curl \ - --data-urlencode "jql=$query" \ - --get \ - --user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \ - --silent \ - --compressed \ - "https://$JIRA_HOSTNAME/rest/api/2/search" | - jq ".issues[] | $jq_template" | - sed -e 's/"\(.*\)"/\1/' | - fzf \ - --preview='jira-details {1}' \ - --preview-window=top:wrap | - sed -e 's/: /:/' -e 's/[^a-zA-Z0-9:]/-/g' | - awk -F ":" '{printf "%s/%s", $1, tolower($2)}' - ) - - echo "$branch_name" -} - -issue_branch=$(choose_issue) -if [ -n "$issue_branch" ]; then - echo "git checkout -b \"$issue_branch\"" -fi diff --git a/legacy/bin/jira-details b/legacy/bin/jira-details deleted file mode 100755 index 7d73fc5..0000000 --- a/legacy/bin/jira-details +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/ -# Requires the following variables to be set: -# - ATLASSIAN_EMAIL -# - ATLASSIAN_API_TOKEN -# - JIRA_HOSTNAME -# - JIRA_PROJECT (for other script) - -issue_details() { - jira_key=$(echo "$1" | cut -d":" -f1) - jq_template='"'\ -'# \(.key): \(.fields.summary)\n'\ -'\n'\ -'*Created*: \(.fields.created)\n'\ -'*Status*: \(.fields.status.statusCategory.name)\n'\ -'*Reporter*: \(.fields.reporter.displayName)\n'\ -'*Priority*: \(.fields.priority.name)\n'\ -"*Epic*: https://$JIRA_HOSTNAME/browse/\(.fields.customfield_10014)\n"\ -'\n'\ -'## Link\n\n'\ -"https://$JIRA_HOSTNAME/browse/\(.key)\n"\ -'\n'\ -'## Description\n\n'\ -'\(.fields.description)'\ -'"' - curl \ - --get \ - --user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \ - --silent \ - --compressed \ - "https://$JIRA_HOSTNAME/rest/api/2/issue/$jira_key" | - jq "$jq_template" | - xargs printf | - bat -l md --color always --style plain -} - -issue_details "$1" diff --git a/legacy/bin/kube-dashboard b/legacy/bin/kube-dashboard deleted file mode 100755 index 73542fd..0000000 --- a/legacy/bin/kube-dashboard +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -kubectl -n kube-system get secret "$( - kubectl -n kube-system get secret | - grep dashboard-admin | - awk '{print $1}' -)" -o json | - jq -j --raw-output '.data.token' | - base64 --decode | - pbcopy - -open http://localhost:8001/api/v1/namespaces/default/services/https:kubernetes-dashboard:https/proxy/#!/login - -kubectl proxy diff --git a/legacy/bin/newest b/legacy/bin/newest deleted file mode 100755 index 5d33ea8..0000000 --- a/legacy/bin/newest +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls | sort-by modified | reverse | keep 5 diff --git a/legacy/bin/oldest b/legacy/bin/oldest deleted file mode 100755 index a9cc938..0000000 --- a/legacy/bin/oldest +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls | sort-by modified | keep 5 diff --git a/legacy/bin/pod b/legacy/bin/pod deleted file mode 100755 index c1d491a..0000000 --- a/legacy/bin/pod +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -# Credit: https://github.com/junegunn/fzf/blob/master/ADVANCED.md - -read -ra tokens < <( - kubectl get pods --all-namespaces | - fzf --info=inline --layout=reverse --header-lines=1 --border \ - --prompt "$(kubectl config current-context | sed 's/-context$//')> " \ - --header $'Press CTRL-O to open log in editor\n\n' \ - --bind ctrl-/:toggle-preview \ - --bind "ctrl-o:execute:${EDITOR:-vim} <(kubectl logs --namespace {1} {2}) > /dev/tty" \ - --preview-window up,follow \ - --preview 'kubectl logs --follow --tail=100000 --namespace {1} {2}' "$@" -) -[ ${#tokens} -gt 1 ] && - kubectl exec -it --namespace "${tokens[0]}" "${tokens[1]}" -- /bin/sh diff --git a/legacy/bin/symlinks b/legacy/bin/symlinks deleted file mode 100755 index 71cd0c2..0000000 --- a/legacy/bin/symlinks +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/local/bin/nu - -ls -al | where type == Symlink | select name target diff --git a/legacy/bin/url-decode b/legacy/bin/url-decode deleted file mode 100755 index 10a20ae..0000000 --- a/legacy/bin/url-decode +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } - -urldecode "$@" diff --git a/legacy/newsboat/com.noah.newsboat.plist b/legacy/newsboat/com.noah.newsboat.plist deleted file mode 100644 index 1c19f9c..0000000 --- a/legacy/newsboat/com.noah.newsboat.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Label - com.noah.newsboat - - ProgramArguments - - /usr/local/bin/newsboat -x reload - - - Nice - 1 - - StartInterval - 1800 - - RunAtLoad - - - StandardErrorPath - /tmp/newsboat.err - - StandardOutPath - /tmp/newsboat.out - - diff --git a/legacy/newsboat/config b/legacy/newsboat/config deleted file mode 100644 index ecd3aba..0000000 --- a/legacy/newsboat/config +++ /dev/null @@ -1,40 +0,0 @@ -browser "$BROWSER %u" -prepopulate-query-feeds yes -feed-sort-order lastupdated -reload-only-visible-feeds yes -text-width 72 - -bind-key j down -bind-key k up -bind-key j next articlelist -bind-key k prev articlelist -bind-key G end -bind-key g home -bind-key d pagedown -bind-key u pageup -bind-key n next-unread -bind-key p prev-unread -bind-key ; macro-prefix -bind-key B bookmark -bind-key f edit-flags - -macro v set browser "mpv %u"; open-in-browser; set browser "$BROWSER %u" -macro p set browser "echo %u"; one; set browser "$BROWSER %u" -macro H set browser "clx view $(echo %u | cut -d '=' -f2)"; one; set browser "$BROWSER %u" -macro h set browser "clx view $(echo %u | cut -d '=' -f2)"; two; set browser "$BROWSER %u" -macro w set browser "w3m -o confirm_qq=false %u"; open-in-browser; set browser "$BROWSER %u" -macro r set browser "url-markdown %u | glow -p -w 72 -"; open-in-browser; set browser "$BROWSER %u" -macro d set browser "youtube-dl -o ~/Downloads/%(title)s.%(ext)s %u &"; open-in-browser-noninteractively; set browser "$BROWSER %u" -macro n set-tag News; reload-all -macro a set-tag All -macro e set-tag Reddit; reload-all -macro y set-tag YouTube; reload-all - -bookmark-cmd "bookmark" - -highlight article "^(Feed|Title|Author|Link|Date):.*" color243 default -highlight article "^(Links):.*" color243 default -highlight article "^(\\[[0-9]+\\]):.*" color243 default -highlight article "^(\\[[0-9]+\\])" color243 default -highlight article "^\\[.*\\]$" color243 default -highlight article "^(Title:).*" color249 default diff --git a/legacy/nix-env.fish b/legacy/nix-env.fish deleted file mode 100644 index b84fba0..0000000 --- a/legacy/nix-env.fish +++ /dev/null @@ -1,137 +0,0 @@ -# Setup Nix - -# We need to distinguish between single-user and multi-user installs. -# This is difficult because there's no official way to do this. -# We could look for the presence of /nix/var/nix/daemon-socket/socket but this will fail if the -# daemon hasn't started yet. /nix/var/nix/daemon-socket will exist if the daemon has ever run, but -# I don't think there's any protection against accidentally running `nix-daemon` as a user. -# We also can't just look for /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh because -# older single-user installs used the default profile instead of a per-user profile. -# We can still check for it first, because all multi-user installs should have it, and so if it's -# not present that's a pretty big indicator that this is a single-user install. If it does exist, -# we still need to verify the install type. To that end we'll look for a root owner and sticky bit -# on /nix/store. Multi-user installs set both, single-user installs don't. It's certainly possible -# someone could do a single-user install as root and then manually set the sticky bit but that -# would be extremely unusual. - -set -l nix_profile_path /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh -set -l single_user_profile_path ~/.nix-profile/etc/profile.d/nix.sh -if test -e $nix_profile_path - # The path exists. Double-check that this is a multi-user install. - # We can't just check for ~/.nix-profile/… because this may be a single-user install running as - # the wrong user. - - # stat is not portable. Splitting the output of ls -nd is reliable on most platforms. - set -l owner (string split -n ' ' (command ls -nd /nix/store 2>/dev/null))[3] - if not test -k /nix/store -a $owner -eq 0 - # /nix/store is either not owned by root or not sticky. Assume single-user. - set nix_profile_path $single_user_profile_path - end -else - # The path doesn't exist. Assume single-user - set nix_profile_path $single_user_profile_path -end - -if test -e $nix_profile_path - # Source the nix setup script - # We're going to run the regular Nix profile under bash and then print out a few variables - for line in (command env -u BASH_ENV bash -c '. "$0"; for name in PATH "${!NIX_@}"; do printf "%s=%s\0" "$name" "${!name}"; done' $nix_profile_path | string split0) - set -xg (string split -m 1 = $line) - end - - # Insert Nix's fish share directories into fish's special variables. - # nixpkgs-installed fish tries to set these up already if NIX_PROFILES is defined, which won't - # be the case when sourcing $__fish_data_dir/share/config.fish normally, but might be for a - # recursive invocation. To guard against that, we'll only insert paths that don't already exit. - # Furthermore, for the vendor_conf.d sourcing, we'll use the pre-existing presence of a path in - # $fish_function_path to determine whether we want to source the relevant vendor_conf.d folder. - - # To start, let's locally define NIX_PROFILES if it doesn't already exist. - set -al NIX_PROFILES - if test (count $NIX_PROFILES) -eq 0 - set -a NIX_PROFILES $HOME/.nix-profile - end - # Replicate the logic from nixpkgs version of $__fish_data_dir/__fish_build_paths.fish. - set -l __nix_profile_paths (string split ' ' -- $NIX_PROFILES)[-1..1] - set -l __extra_completionsdir \ - $__nix_profile_paths/etc/fish/completions \ - $__nix_profile_paths/share/fish/vendor_completions.d - set -l __extra_functionsdir \ - $__nix_profile_paths/etc/fish/functions \ - $__nix_profile_paths/share/fish/vendor_functions.d - set -l __extra_confdir \ - $__nix_profile_paths/etc/fish/conf.d \ - $__nix_profile_paths/share/fish/vendor_conf.d - ### Configure fish_function_path ### - # Remove any of our extra paths that may already exist. - # Record the equivalent __extra_confdir path for any function path that exists. - set -l existing_conf_paths - for path in $__extra_functionsdir - if set -l idx (contains --index -- $path $fish_function_path) - set -e fish_function_path[$idx] - set -a existing_conf_paths $__extra_confdir[(contains --index -- $path $__extra_functionsdir)] - end - end - # Insert the paths before $__fish_data_dir. - if set -l idx (contains --index -- $__fish_data_dir/functions $fish_function_path) - # Fish has no way to simply insert into the middle of an array. - set -l new_path $fish_function_path[1..$idx] - set -e new_path[$idx] - set -a new_path $__extra_functionsdir - set fish_function_path $new_path $fish_function_path[$idx..-1] - else - set -a fish_function_path $__extra_functionsdir - end - - ### Configure fish_complete_path ### - # Remove any of our extra paths that may already exist. - for path in $__extra_completionsdir - if set -l idx (contains --index -- $path $fish_complete_path) - set -e fish_complete_path[$idx] - end - end - # Insert the paths before $__fish_data_dir. - if set -l idx (contains --index -- $__fish_data_dir/completions $fish_complete_path) - set -l new_path $fish_complete_path[1..$idx] - set -e new_path[$idx] - set -a new_path $__extra_completionsdir - set fish_complete_path $new_path $fish_complete_path[$idx..-1] - else - set -a fish_complete_path $__extra_completionsdir - end - - ### Source conf directories ### - # The built-in directories were already sourced during shell initialization. - # Any __extra_confdir that came from $__fish_data_dir/__fish_build_paths.fish was also sourced. - # As explained above, we're using the presence of pre-existing paths in $fish_function_path as a - # signal that the corresponding conf dir has also already been sourced. - # In order to simulate this, we'll run through the same algorithm as found in - # $__fish_data_dir/config.fish except we'll avoid sourcing the file if it comes from an - # already-sourced location. - # Caveats: - # * Files will be sourced in a different order than we'd ideally do (because we're coming in - # after the fact to source them). - # * If there are existing extra conf paths, files in them may have been sourced that should have - # been suppressed by paths we're inserting in front. - # * Similarly any files in $__fish_data_dir/vendor_conf.d that should have been suppressed won't - # have been. - set -l sourcelist - for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish - # We know these paths were sourced already. Just record them. - set -l basename (string replace -r '^.*/' '' -- $file) - contains -- $basename $sourcelist - or set -a sourcelist $basename - end - for root in $__extra_confdir - for file in $root/*.fish - set -l basename (string replace -r '^.*/' '' -- $file) - contains -- $basename $sourcelist - and continue - set -a sourcelist $basename - contains -- $root $existing_conf_paths - and continue # this is a pre-existing path, it will have been sourced already - [ -f $file -a -r $file ] - and source $file - end - end -end diff --git a/legacy/scripts/configure_macos b/legacy/scripts/configure_macos deleted file mode 100755 index 1bd8e00..0000000 --- a/legacy/scripts/configure_macos +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh - -echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)" -defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 - -echo "Automatically show and hide the dock" -defaults write com.apple.dock autohide -bool true - -echo "Automatically show and hide the menu bar" -defaults write NSGlobalDomain _HIHideMenuBar -bool true - -echo "Make Dock icons of hidden applications translucent" -defaults write com.apple.dock showhidden -bool true - -echo "Use current directory as default search scope in Finder" -defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" - -echo "Expand save panel by default" -defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true - -echo "Expand print panel by default" -defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true - -echo "Disable the \"Are you sure you want to open this application?\" dialog" -defaults write com.apple.LaunchServices LSQuarantine -bool false - -echo "Enable highlight hover effect for the grid view of a stack (Dock)" -defaults write com.apple.dock mouse-over-hilte-stack -bool true - -echo "Enable spring loading for all Dock items" -defaults write enable-spring-load-actions-on-all-items -bool true - -echo "Disable press-and-hold for keys in favor of key repeat" -defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false -defaults write -g ApplePressAndHoldEnabled -bool false - -echo "Set a blazingly fast keyboard repeat rate" -defaults write NSGlobalDomain KeyRepeat -int 2 - -echo "Set a shorter Delay until key repeat" -defaults write NSGlobalDomain InitialKeyRepeat -int 12 - -echo "Disable disk image verification" -defaults write com.apple.frameworks.diskimages skip-verify -bool true -defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true -defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true - -echo "Avoid creating .DS_Store files on network volumes" -defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - -echo "Disable the warning when changing a file extension" -defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false - -# echo "Enable snap-to-grid for desktop icons" -# /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist - -echo "Disable the warning before emptying the Trash" -defaults write com.apple.finder WarnOnEmptyTrash -bool false - -echo "Disable tap to click (Trackpad)" -defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool false - -echo "Enable Safari’s debug menu" -defaults write com.apple.Safari IncludeInternalDebugMenu -bool true - -echo "Make Safari’s search banners default to Contains instead of Starts With" -defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false - -echo "Add a context menu item for showing the Web Inspector in web views" -defaults write NSGlobalDomain WebKitDeveloperExtras -bool true - -echo "Save to disk (not to iCloud) by default" -defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false - -echo "Disable automatic capitalization as it’s annoying when typing code" -defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false - -echo "Disable smart dashes as they’re annoying when typing code" -defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false - -echo "Disable automatic period substitution as it’s annoying when typing code" -defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false - -echo "Disable smart quotes as they’re annoying when typing code" -defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false - -echo "Disable auto-correct" -defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false - -echo "Use scroll gesture with the Ctrl (^) modifier key to zoom" -defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true -defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 -echo "Follow the keyboard focus while zoomed in" -defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true - -echo "Require password immediately after sleep or screen saver begins" -defaults write com.apple.screensaver askForPassword -int 1 -defaults write com.apple.screensaver askForPasswordDelay -int 0 - -echo "Save screenshots to downloads" -defaults write com.apple.screencapture location -string "${HOME}/Downloads" - -echo "Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons" -defaults write com.apple.finder QuitMenuItem -bool true - -echo "Show the ~/Library folder" -chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library - -# Noah Prefs -echo "Enable dock magnification" -defaults write com.apple.dock magnification -bool true - -echo "Set dock size" -defaults write com.apple.dock largesize -int 48 -defaults write com.apple.dock tilesize -int 44 - -echo "Choose and order dock icons" -__dock_item() { - printf '%s%s%s%s%s' \ - 'tile-datafile-data' \ - '_CFURLString' \ - "$1" \ - '_CFURLStringType0' \ - '' -} - -defaults write com.apple.dock persistent-apps -array \ - "$(__dock_item /Applications/1Password\ 7.app)" \ - "$(__dock_item /Applications/Slack.app)" \ - "$(__dock_item /System/Applications/Calendar.app)" \ - "$(__dock_item /Applications/Firefox.app)" \ - "$(__dock_item /System/Applications/Messages.app)" \ - "$(__dock_item /System/Applications/Mail.app)" \ - "$(__dock_item /Applications/Mimestream.app)" \ - "$(__dock_item /Applications/zoom.us.app)" \ - "$(__dock_item /Applications/Obsidian.app)" \ - "$(__dock_item /Applications/Alacritty.app)" \ - "$(__dock_item /System/Applications/System\ Preferences.app)" - -echo "No recent items in dock" -defaults write com.apple.dock show-recents -bool FALSE - -echo "Switch to dark mode" -defaults write "Apple Global Domain" "AppleInterfaceStyle" "Dark" - -echo "Turn on Scroll Reverser" -open /Applications/Scroll\ Reverser.app -osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/Scroll Reverser.app", hidden:false}' - -echo "Allow apps from anywhere" -SPCTL=$(spctl --status) -if ! [ "$SPCTL" = "assessments disabled" ] -then - sudo spctl --master-disable -fi - -# --- - -echo "Reset Launchpad" -# [ -e ~/Library/Application\ Support/Dock/*.db ] && rm ~/Library/Application\ Support/Dock/*.db -rm ~/Library/Application\ Support/Dock/*.db - -echo "Show the ~/Library folder" -chflags nohidden ~/Library - -# Clean up -echo "Kill affected applications" -for app in Safari Finder Dock Mail SystemUIServer; do killall "$app" >/dev/null 2>&1; done diff --git a/legacy/scripts/npm b/legacy/scripts/npm deleted file mode 100755 index 2ad7268..0000000 --- a/legacy/scripts/npm +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -npm update -g -npm install -g pyright -npm install -g diagnostic-languageserver diff --git a/legacy/scripts/rust b/legacy/scripts/rust deleted file mode 100755 index 2456f0b..0000000 --- a/legacy/scripts/rust +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -install_rust() { - if ! (which ~/.cargo/bin/rustup > /dev/null) - then - echo "installing rustup" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - fi - - echo "rustup ✓" -} - -update_rust() { - ~/.cargo/bin/rustup update > /dev/null 2>&1 - rust_version=$(~/.cargo/bin/rustc --version | awk '{print $2}') - - echo "latest rust: $rust_version ✓" -} - -download_rust_analyzer() { - if ! (which rust-analyzer > /dev/null) - then - echo "downloading rust analyzer" - rust_analyzer_bin=/usr/local/bin/rust-analyzer - curl -s -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-mac -o $rust_analyzer_bin - chmod +x $rust_analyzer_bin - fi - - echo "rust-analyzer ✓" -} - -# cargo-edit: quickly add and remove packages -# whatfeatures: see optional features for a package -install_cargos() { - set -- \ - 'cargo-edit' \ - 'cargo-whatfeatures' - for program do - cargo install "$program" - done - - echo "cargos ✓" -} - -install_rust -update_rust -download_rust_analyzer -install_cargos diff --git a/legacy/scripts/setup_cheatsheet b/legacy/scripts/setup_cheatsheet deleted file mode 100755 index e10058c..0000000 --- a/legacy/scripts/setup_cheatsheet +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "downloading cheatsheet" -curl https://cht.sh/:cht.sh > ~/.local/bin/cheat -chmod 755 ~/.local/bin/cheat -echo "cheatsheet ✓" diff --git a/legacy/scripts/setup_fish b/legacy/scripts/setup_fish deleted file mode 100755 index 269833d..0000000 --- a/legacy/scripts/setup_fish +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env fish - -set -U FISH_DIR (readlink ~/.config/fish) # Used for getting to this repo -set -Ux DOTS (dirname $FISH_DIR) # Directory of this config repo -set -U CDPATH . $HOME # Directories available for immediate cd -set -Ux EDITOR nvim # Preferred text editor -set -U PROJ $HOME/dev/work # Projects directory -set -Ux NOTES_PATH "$HOME/dev/personal/notes" # Notes directory -set -Ux MANPAGER "nvim +Man!" # Used for reading man pages -set -Ux DIRENV_LOG_FORMAT "" # Disable direnv output -set -Ux BROWSER "/Applications/Firefox.app/Contents/MacOS/firefox" - -# Load abbreviations -abbrs - -# Turn off greeting -set -U fish_greeting "" - -# Set colors (Base16 Eighties) -set -U fish_color_normal normal -set -U fish_color_command 99cc99 -set -U fish_color_quote ffcc66 -set -U fish_color_redirection d3d0c8 -set -U fish_color_end cc99cc -set -U fish_color_error f2777a -set -U fish_color_selection white --bold --background=brblack -set -U fish_color_search_match bryellow --background=brblack -set -U fish_color_history_current --bold -set -U fish_color_operator 6699cc -set -U fish_color_escape 66cccc -set -U fish_color_cwd green -set -U fish_color_cwd_root red -set -U fish_color_valid_path --underline -set -U fish_color_autosuggestion 747369 -set -U fish_color_user brgreen -set -U fish_color_host normal -set -U fish_color_cancel -r -set -U fish_pager_color_completion normal -set -U fish_pager_color_description B3A06D yellow -set -U fish_pager_color_prefix white --bold --underline -set -U fish_pager_color_progress brwhite --background=cyan -set -U fish_color_comment ffcc66 -set -U fish_color_param d3d0c8 -set -U fish_color_match 6699cc - -echo "fish setup ✓" diff --git a/legacy/scripts/setup_ytfzf b/legacy/scripts/setup_ytfzf deleted file mode 100755 index 0408a3a..0000000 --- a/legacy/scripts/setup_ytfzf +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -echo "downloading ytfzf" -mkdir -p ~/.local/bin -curl -sL "https://raw.githubusercontent.com/pystardust/ytfzf/master/ytfzf" >~/.local/bin/ytfzf -chmod 755 ~/.local/bin/ytfzf -echo "ytfzf ✓" diff --git a/legacy/templates/kubernetes/clusterrole.yaml b/legacy/templates/kubernetes/clusterrole.yaml deleted file mode 100644 index 10fc326..0000000 --- a/legacy/templates/kubernetes/clusterrole.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: -rules: - - apiGroups: [""] - resources: - verbs: [] diff --git a/legacy/templates/kubernetes/clusterrolebinding.yaml b/legacy/templates/kubernetes/clusterrolebinding.yaml deleted file mode 100644 index 3d5095e..0000000 --- a/legacy/templates/kubernetes/clusterrolebinding.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: -subjects: -- kind: ServiceAccount - name: - namespace: default diff --git a/legacy/templates/kubernetes/configmap.yaml b/legacy/templates/kubernetes/configmap.yaml deleted file mode 100644 index 0dfc20a..0000000 --- a/legacy/templates/kubernetes/configmap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: - namespace: default - annotations: - replicator.v1.mittwald.de/replicate-to: ".*" -data: diff --git a/legacy/templates/kubernetes/deployment.yaml b/legacy/templates/kubernetes/deployment.yaml deleted file mode 100644 index 204bcfc..0000000 --- a/legacy/templates/kubernetes/deployment.yaml +++ /dev/null @@ -1,33 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: - template: - metadata: - labels: - app: - spec: - serviceAccountName: - containers: - - name: - image: - imagePullPolicy: Always - envFrom: - - configMapRef: - name: - - secretRef: - name: - ports: - - containerPort: - protocol: TCP - resources: - limits: - cpu: - requests: - cpu: diff --git a/legacy/templates/kubernetes/ingress.yaml b/legacy/templates/kubernetes/ingress.yaml deleted file mode 100644 index df7b928..0000000 --- a/legacy/templates/kubernetes/ingress.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: networking.k8s.io/v1beta1 # must be beta until k8s 1.19 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: alb - alb.ingress.kubernetes.io/group.name: - alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]' - alb.ingress.kubernetes.io/scheme: internet-facing - alb.ingress.kubernetes.io/security-groups: - alb.ingress.kubernetes.io/tags: Project= - alb.ingress.kubernetes.io/target-type: instance - name: - namespace: -spec: - rules: - - host: - http: - paths: - - backend: - serviceName: - servicePort: diff --git a/legacy/templates/kubernetes/role.yaml b/legacy/templates/kubernetes/role.yaml deleted file mode 100644 index 395080d..0000000 --- a/legacy/templates/kubernetes/role.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: - namespace: default -rules: -- apiGroups: [""] - resourceNames: - resources: - verbs: diff --git a/legacy/templates/kubernetes/rolebinding.yaml b/legacy/templates/kubernetes/rolebinding.yaml deleted file mode 100644 index 6fcb96c..0000000 --- a/legacy/templates/kubernetes/rolebinding.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: - namespace: default -roleRef: - kind: - name: - apiGroup: rbac.authorization.k8s.io -subjects: -- kind: - name: - apiGroup: rbac.authorization.k8s.io diff --git a/legacy/templates/kubernetes/secret.yaml b/legacy/templates/kubernetes/secret.yaml deleted file mode 100644 index a8025a0..0000000 --- a/legacy/templates/kubernetes/secret.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: - namespace: default - annotations: - replicator.v1.mittwald.de/replicate-to: ".*" -data: diff --git a/legacy/templates/kubernetes/service.yaml b/legacy/templates/kubernetes/service.yaml deleted file mode 100644 index e375f08..0000000 --- a/legacy/templates/kubernetes/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - alb.ingress.kubernetes.io/healthcheck-path: - name: - namespace: default -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 80 - selector: - app: - type: NodePort diff --git a/legacy/templates/kubernetes/serviceaccount.yaml b/legacy/templates/kubernetes/serviceaccount.yaml deleted file mode 100644 index 1c89f57..0000000 --- a/legacy/templates/kubernetes/serviceaccount.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: - namespace: default diff --git a/legacy/templates/programs/skeleton.py b/legacy/templates/programs/skeleton.py deleted file mode 100644 index 395f57d..0000000 --- a/legacy/templates/programs/skeleton.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -""" -Program -""" - -def main(): - """Run the program""" - pass - -if __name__ == "__main__": - main() diff --git a/legacy/templates/programs/skeleton.sh b/legacy/templates/programs/skeleton.sh deleted file mode 100644 index 1e5bc66..0000000 --- a/legacy/templates/programs/skeleton.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then - cat < Date: Mon, 20 Feb 2023 22:42:22 -0500 Subject: [PATCH 192/391] enable charm --- hosts/lookingglass/default.nix | 3 ++- hosts/tempest/default.nix | 1 + modules/common/shell/utilities.nix | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hosts/lookingglass/default.nix b/hosts/lookingglass/default.nix index 3f05927..30c7e35 100644 --- a/hosts/lookingglass/default.nix +++ b/hosts/lookingglass/default.nix @@ -29,6 +29,7 @@ darwin.lib.darwinSystem { nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays; # Set registry to flake packages, used for nix X commands nix.registry.nixpkgs.flake = nixpkgs; + charm.enable = true; neovim.enable = true; mail.enable = true; mail.aerc.enable = true; @@ -42,7 +43,7 @@ darwin.lib.darwinSystem { python.enable = true; lua.enable = true; kubernetes.enable = true; - "1password".enable = true; + _1password.enable = true; } ]; } diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix index 2341e9e..17eb7ad 100644 --- a/hosts/tempest/default.nix +++ b/hosts/tempest/default.nix @@ -33,6 +33,7 @@ nixpkgs.lib.nixosSystem { wsl.enable = false; publicKey = null; + charm.enable = true; neovim.enable = true; media.enable = true; firefox.enable = true; diff --git a/modules/common/shell/utilities.nix b/modules/common/shell/utilities.nix index 38aca7d..4ffa962 100644 --- a/modules/common/shell/utilities.nix +++ b/modules/common/shell/utilities.nix @@ -41,7 +41,6 @@ in { tealdeer # Cheatsheets tree # View directory hierarchy htop # Show system processes - glow # Pretty markdown previews qrencode # Generate qr codes vimv-rs # Batch rename files dig # DNS lookup From 48d33a9ef52c8c997892c456c3311554bef15be4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:28:43 -0500 Subject: [PATCH 193/391] update to kernel 6.2 --- flake.lock | 6 +++--- modules/nixos/hardware/boot.nix | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 2fca296..5997d31 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1676110339, - "narHash": "sha256-kOS/L8OOL2odpCOM11IevfHxcUeE0vnZUQ74EOiwXcs=", + "lastModified": 1676973346, + "narHash": "sha256-rft8oGMocTAhUVqG3LW6I8K/Fo9ICGmNjRqaWTJwav0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e5530aba13caff5a4f41713f1265b754dc2abfd8", + "rev": "d0d55259081f0b97c828f38559cad899d351cad1", "type": "github" }, "original": { diff --git a/modules/nixos/hardware/boot.nix b/modules/nixos/hardware/boot.nix index 875b586..47f8b9c 100644 --- a/modules/nixos/hardware/boot.nix +++ b/modules/nixos/hardware/boot.nix @@ -40,4 +40,7 @@ boot.supportedFilesystems = lib.mkIf (config.physical && pkgs.stdenv.isLinux) [ "ntfs" ]; + # Use latest released Linux kernel by default + boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + } From 6d0b0e3560eceed6655979c003420edda4b2cc92 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 22 Feb 2023 23:45:47 -0500 Subject: [PATCH 194/391] enable feral gamemode wrapper --- modules/nixos/gaming/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nixos/gaming/default.nix b/modules/nixos/gaming/default.nix index c1fe519..121b73a 100644 --- a/modules/nixos/gaming/default.nix +++ b/modules/nixos/gaming/default.nix @@ -16,5 +16,6 @@ driSupport = true; driSupport32Bit = true; }; + programs.gamemode.enable = true; }; } From 252b3d5dace14028a089a6971c7e15d9f0d0aabb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 22 Feb 2023 23:46:24 -0500 Subject: [PATCH 195/391] temp: broken sleep attempt --- modules/nixos/hardware/sleep.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/nixos/hardware/sleep.nix b/modules/nixos/hardware/sleep.nix index 1a1aa5f..f5db8a6 100644 --- a/modules/nixos/hardware/sleep.nix +++ b/modules/nixos/hardware/sleep.nix @@ -4,9 +4,17 @@ # Prevent wake from keyboard powerManagement.powerDownCommands = '' - for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done + # for power in /sys/bus/usb/devices/*/power; do echo disabled > ''${power}/wakeup; done + + # AMD issue: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Instantaneous_wakeups_from_suspend + for power in /sys/bus/i2c/devices/i2c-*/device/power; do echo disabled > ''${power}/wakeup; done ''; + # From here: https://www.reddit.com/r/NixOS/comments/wcu34f/how_would_i_do_this_in_nix/ + # services.udev.extraRules = '' + # ACTION=="add", SUBSYSTEM=="i2c", ATTRS{idVendor}=="", ATTRS{idProduct}=="" RUN+="${pkgs.bash}/bin/bash -c 'echo disabled > /sys/bus/i2c/devices/i2c-*/power/wakeup'" + # ''; + }; } From ac3d5e495c4deba836781dcb0f24d56ad760b66b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 23 Feb 2023 00:13:16 -0500 Subject: [PATCH 196/391] temp: start disk setup for swan --- hosts/swan/disks.nix | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 hosts/swan/disks.nix diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix new file mode 100644 index 0000000..f1d139c --- /dev/null +++ b/hosts/swan/disks.nix @@ -0,0 +1,131 @@ +{ bootDisk, storageDisks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { + disk = { + boot = { + type = "disk"; + device = "/dev/whatever"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + type = "partition"; + name = "root"; + start = "512MiB"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + } + ]; + }; + }; + a = { + type = "disk"; + device = builtins.elemAt storageDisks 1; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + }; + zpool = { + tank = { + type = "zpool"; + mode = "raidz1"; + rootFsOptions = { + compression = "on"; # lz4 by default + "com.sun:auto-snapshot" = "false"; + ashift = 12; + }; + # mountpoint = "/"; + + datasets = { + media = { + zfs_type = "filesystem"; + mountpoint = "none"; + options."com.sun:auto-snapshot" = "false"; + }; + # "media/movies" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/movies"; + # options.recordsize = "1M"; + # }; + # "media/tv" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/tv"; + # options.recordsize = "1M"; + # }; + # "media/books" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/books"; + # }; + # archive = { + # zfs_type = "filesystem"; + # mountpoint = "/archive"; + # options.compression = "zstd"; + # options."com.sun:auto-snapshot" = "true"; + # }; + # zfs_unmounted_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "none"; + # }; + # zfs_legacy_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "legacy"; + # mountpoint = "/zfs_legacy_fs"; + # }; + # zfs_testvolume = { + # zfs_type = "volume"; + # size = "10M"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/ext4onzfs"; + # }; + # }; + encrypted = { + zfs_type = "filesystem"; + size = "20M"; + options = { + mountpoint = "none"; + encryption = "aes-256-gcm"; + keyformat = "passphrase"; + keylocation = "file:///tmp/secret.key"; + }; + }; + "encrypted/test" = { + zfs_type = "filesystem"; + size = "2M"; + mountpoint = "/zfs_crypted"; + }; + }; + }; + }; +} From 18c9e1efc8d1ff8e3d10f341f8be9fb27c7ade9a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 09:22:16 -0500 Subject: [PATCH 197/391] ssh settings for staff usb --- generators/staff/default.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/generators/staff/default.nix b/generators/staff/default.nix index 6d4fe0a..dc43df4 100644 --- a/generators/staff/default.nix +++ b/generators/staff/default.nix @@ -13,5 +13,23 @@ nixos-generators.nixosGenerate { users.extraUsers.root.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s" ]; + services.openssh = { + enable = true; + ports = [ 22 ]; + allowSFTP = true; + settings = { + GatewayPorts = "no"; + X11Forwarding = false; + PasswordAuthentication = false; + PermitRootLogin = "yes"; + }; + }; + environment.systemPackages = + with (import inputs.nixpkgs { inherit system; }); [ + git + vim + wget + curl + ]; }]; } From 7a547f99c0f40a52d845b6d4091559e1e800e325 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 09:45:49 -0500 Subject: [PATCH 198/391] add disko input and hardware module for swan --- flake.lock | 21 ++ flake.nix | 8 + hosts/swan/default.nix | 10 +- hosts/swan/disks.nix | 272 +++++++++++++++----------- hosts/swan/hardware-configuration.nix | 29 +++ 5 files changed, 219 insertions(+), 121 deletions(-) create mode 100644 hosts/swan/hardware-configuration.nix diff --git a/flake.lock b/flake.lock index 5997d31..5e23f7f 100644 --- a/flake.lock +++ b/flake.lock @@ -69,6 +69,26 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677116397, + "narHash": "sha256-2OHwhv4k1SDEuNxhq+zluvrd5pbW8d4TP9NKW4B8iO8=", + "owner": "nix-community", + "repo": "disko", + "rev": "8fddb2fd721365fa77ff68b709539639d4dc65d7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "firefox-darwin": { "inputs": { "nixpkgs": "nixpkgs" @@ -396,6 +416,7 @@ "bufferline-nvim-src": "bufferline-nvim-src", "cmp-nvim-lsp-src": "cmp-nvim-lsp-src", "darwin": "darwin", + "disko": "disko", "firefox-darwin": "firefox-darwin", "home-manager": "home-manager", "nil": "nil", diff --git a/flake.nix b/flake.nix index 55c564c..7c2cab3 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,12 @@ # Use official Firefox binary for macOS firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin"; + # Manage disk format and partitioning + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Wallpapers wallpapers = { url = "gitlab:exorcist365/wallpapers"; @@ -146,6 +152,8 @@ darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; + diskoConfiguration = { swan = import ./hosts/swan/disks.nix { }; }; + # Package servers into images with a generator packages = forAllSystems (system: { diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 024cdd4..ba632f0 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,11 +10,13 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix + ./disks.nix ../../modules/common ../../modules/nixos (removeAttrs globals [ "mail.server" ]) wsl.nixosModules.wsl home-manager.nixosModules.home-manager + disko.nixosModules.disko { server = true; gui.enable = false; @@ -37,11 +39,11 @@ nixpkgs.lib.nixosSystem { boot.zfs.enabled = true; boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; - boot.zfs.extraPools = [ "mypool" ]; - services.zfs.autoScrub.enable = true; - services.zfs.autoScrub.interval = "daily"; + # boot.zfs.extraPools = [ "mypool" ]; + # services.zfs.autoScrub.enable = true; + # services.zfs.autoScrub.interval = "daily"; - services.nfs.server.enable = true; + # services.nfs.server.enable = true; } ]; diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index f1d139c..b12d919 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -1,129 +1,167 @@ -{ bootDisk, storageDisks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { - disk = { - boot = { - type = "disk"; - device = "/dev/whatever"; - content = { - type = "table"; - format = "gpt"; - partitions = [ - { +{ ... }: { + disko.devices = { + disk = { + boot = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + type = "partition"; + name = "root"; + start = "512MiB"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + } + ]; + }; + }; + sda = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ type = "partition"; - name = "ESP"; - start = "0"; - end = "512MiB"; - fs-type = "fat32"; - bootable = true; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - }; - } - { - type = "partition"; - name = "root"; - start = "512MiB"; + name = "zfs"; + start = "128MiB"; end = "100%"; - part-type = "primary"; - bootable = true; content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; + type = "zfs"; + pool = "tank"; }; - } - ]; + }]; + }; + }; + sdb = { + type = "disk"; + device = "/dev/sdb"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + sdc = { + type = "disk"; + device = "/dev/sdc"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; }; }; - a = { - type = "disk"; - device = builtins.elemAt storageDisks 1; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - }; - zpool = { - tank = { - type = "zpool"; - mode = "raidz1"; - rootFsOptions = { - compression = "on"; # lz4 by default - "com.sun:auto-snapshot" = "false"; - ashift = 12; - }; - # mountpoint = "/"; + zpool = { + tank = { + type = "zpool"; + mode = "raidz1"; + rootFsOptions = { + compression = "on"; # lz4 by default + "com.sun:auto-snapshot" = "false"; + ashift = 12; + }; + # mountpoint = "/"; - datasets = { - media = { - zfs_type = "filesystem"; - mountpoint = "none"; - options."com.sun:auto-snapshot" = "false"; - }; - # "media/movies" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/movies"; - # options.recordsize = "1M"; - # }; - # "media/tv" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/tv"; - # options.recordsize = "1M"; - # }; - # "media/books" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/books"; - # }; - # archive = { - # zfs_type = "filesystem"; - # mountpoint = "/archive"; - # options.compression = "zstd"; - # options."com.sun:auto-snapshot" = "true"; - # }; - # zfs_unmounted_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "none"; - # }; - # zfs_legacy_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "legacy"; - # mountpoint = "/zfs_legacy_fs"; - # }; - # zfs_testvolume = { - # zfs_type = "volume"; - # size = "10M"; - # content = { - # type = "filesystem"; - # format = "ext4"; - # mountpoint = "/ext4onzfs"; - # }; - # }; - encrypted = { - zfs_type = "filesystem"; - size = "20M"; - options = { + datasets = { + media = { + zfs_type = "filesystem"; mountpoint = "none"; - encryption = "aes-256-gcm"; - keyformat = "passphrase"; - keylocation = "file:///tmp/secret.key"; + options."com.sun:auto-snapshot" = "false"; }; - }; - "encrypted/test" = { - zfs_type = "filesystem"; - size = "2M"; - mountpoint = "/zfs_crypted"; + # "media/movies" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/movies"; + # options.recordsize = "1M"; + # }; + # "media/tv" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/tv"; + # options.recordsize = "1M"; + # }; + # "media/books" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/books"; + # }; + # archive = { + # zfs_type = "filesystem"; + # mountpoint = "/archive"; + # options.compression = "zstd"; + # options."com.sun:auto-snapshot" = "true"; + # }; + # zfs_unmounted_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "none"; + # }; + # zfs_legacy_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "legacy"; + # mountpoint = "/zfs_legacy_fs"; + # }; + # zfs_testvolume = { + # zfs_type = "volume"; + # size = "10M"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/ext4onzfs"; + # }; + # }; + # encrypted = { + # zfs_type = "filesystem"; + # size = "20M"; + # options = { + # mountpoint = "none"; + # encryption = "aes-256-gcm"; + # keyformat = "passphrase"; + # keylocation = "file:///tmp/secret.key"; + # }; + # }; + # "encrypted/test" = { + # zfs_type = "filesystem"; + # size = "2M"; + # mountpoint = "/zfs_crypted"; + # }; }; }; }; diff --git a/hosts/swan/hardware-configuration.nix b/hosts/swan/hardware-configuration.nix new file mode 100644 index 0000000..bcf62c3 --- /dev/null +++ b/hosts/swan/hardware-configuration.nix @@ -0,0 +1,29 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot.initrd.availableKernelModules = + [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; +} From 741692e6f19f575d7e86e2e24e3e783f4d7257f0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 09:49:40 -0500 Subject: [PATCH 199/391] fix: typo in disko config --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7c2cab3..9de3c46 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,7 @@ darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; - diskoConfiguration = { swan = import ./hosts/swan/disks.nix { }; }; + diskoConfigurations = { swan = import ./hosts/swan/disks.nix { }; }; # Package servers into images with a generator packages = forAllSystems (system: { From 3dd7fa12b01e6a0a9828244a76cdbc95b5c4e05a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 09:55:57 -0500 Subject: [PATCH 200/391] don't make disks.nix proper nixos module --- hosts/swan/default.nix | 3 +-- hosts/swan/disks.nix | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index ba632f0..170c795 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,10 +10,9 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix - ./disks.nix ../../modules/common ../../modules/nixos - (removeAttrs globals [ "mail.server" ]) + (import ./disks.nix) wsl.nixosModules.wsl home-manager.nixosModules.home-manager disko.nixosModules.disko diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index b12d919..3658b3f 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -1,4 +1,4 @@ -{ ... }: { +{ disko.devices = { disk = { boot = { From 0ba2492c6150b63ff93f3716df45fbae8b14f893 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 09:57:06 -0500 Subject: [PATCH 201/391] don't import disks.nix as function --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 9de3c46..97725dd 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,7 @@ darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; - diskoConfigurations = { swan = import ./hosts/swan/disks.nix { }; }; + diskoConfigurations = { swan = import ./hosts/swan/disks.nix; }; # Package servers into images with a generator packages = forAllSystems (system: { From 80d0451ff33619c06831169b0388f33bba6d8275 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 09:57:58 -0500 Subject: [PATCH 202/391] Revert "don't make disks.nix proper nixos module" This reverts commit 3dd7fa12b01e6a0a9828244a76cdbc95b5c4e05a. --- hosts/swan/default.nix | 3 ++- hosts/swan/disks.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 170c795..ba632f0 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,9 +10,10 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix + ./disks.nix ../../modules/common ../../modules/nixos - (import ./disks.nix) + (removeAttrs globals [ "mail.server" ]) wsl.nixosModules.wsl home-manager.nixosModules.home-manager disko.nixosModules.disko diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index 3658b3f..b12d919 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -1,4 +1,4 @@ -{ +{ ... }: { disko.devices = { disk = { boot = { From 67af160088d14ad6e07c5e19df2422270053dbf6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:02:54 -0500 Subject: [PATCH 203/391] back to plain attrset for disko --- hosts/swan/default.nix | 2 +- hosts/swan/disks.nix | 306 ++++++++++++++++++++--------------------- 2 files changed, 153 insertions(+), 155 deletions(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index ba632f0..4be4e43 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,7 +10,6 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix - ./disks.nix ../../modules/common ../../modules/nixos (removeAttrs globals [ "mail.server" ]) @@ -18,6 +17,7 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager disko.nixosModules.disko { + disko.devices = import ./disks.nix; server = true; gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index b12d919..cccf648 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -1,168 +1,166 @@ -{ ... }: { - disko.devices = { - disk = { - boot = { - type = "disk"; - device = "/dev/nvme0n1"; - content = { - type = "table"; - format = "gpt"; - partitions = [ - { - type = "partition"; - name = "ESP"; - start = "0"; - end = "512MiB"; - fs-type = "fat32"; - bootable = true; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - }; - } - { - type = "partition"; - name = "root"; - start = "512MiB"; - end = "100%"; - part-type = "primary"; - bootable = true; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - } - ]; - }; - }; - sda = { - type = "disk"; - device = "/dev/sda"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ +{ + disk = { + boot = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; content = { - type = "zfs"; - pool = "tank"; + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; }; - }]; - }; - }; - sdb = { - type = "disk"; - device = "/dev/sdb"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ + } + { type = "partition"; - name = "zfs"; - start = "128MiB"; + name = "root"; + start = "512MiB"; end = "100%"; + part-type = "primary"; + bootable = true; content = { - type = "zfs"; - pool = "tank"; + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; }; - }]; - }; - }; - sdc = { - type = "disk"; - device = "/dev/sdc"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; + } + ]; }; }; - zpool = { - tank = { - type = "zpool"; - mode = "raidz1"; - rootFsOptions = { - compression = "on"; # lz4 by default - "com.sun:auto-snapshot" = "false"; - ashift = 12; - }; - # mountpoint = "/"; - - datasets = { - media = { - zfs_type = "filesystem"; - mountpoint = "none"; - options."com.sun:auto-snapshot" = "false"; + sda = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; }; - # "media/movies" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/movies"; - # options.recordsize = "1M"; - # }; - # "media/tv" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/tv"; - # options.recordsize = "1M"; - # }; - # "media/books" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/books"; - # }; - # archive = { - # zfs_type = "filesystem"; - # mountpoint = "/archive"; - # options.compression = "zstd"; - # options."com.sun:auto-snapshot" = "true"; - # }; - # zfs_unmounted_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "none"; - # }; - # zfs_legacy_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "legacy"; - # mountpoint = "/zfs_legacy_fs"; - # }; - # zfs_testvolume = { - # zfs_type = "volume"; - # size = "10M"; - # content = { - # type = "filesystem"; - # format = "ext4"; - # mountpoint = "/ext4onzfs"; - # }; - # }; - # encrypted = { - # zfs_type = "filesystem"; - # size = "20M"; - # options = { - # mountpoint = "none"; - # encryption = "aes-256-gcm"; - # keyformat = "passphrase"; - # keylocation = "file:///tmp/secret.key"; - # }; - # }; - # "encrypted/test" = { - # zfs_type = "filesystem"; - # size = "2M"; - # mountpoint = "/zfs_crypted"; - # }; + }]; + }; + }; + sdb = { + type = "disk"; + device = "/dev/sdb"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + sdc = { + type = "disk"; + device = "/dev/sdc"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + }; + zpool = { + tank = { + type = "zpool"; + mode = "raidz1"; + rootFsOptions = { + compression = "on"; # lz4 by default + "com.sun:auto-snapshot" = "false"; + ashift = 12; + }; + # mountpoint = "/"; + + datasets = { + media = { + zfs_type = "filesystem"; + mountpoint = "none"; + options."com.sun:auto-snapshot" = "false"; }; + # "media/movies" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/movies"; + # options.recordsize = "1M"; + # }; + # "media/tv" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/tv"; + # options.recordsize = "1M"; + # }; + # "media/books" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/books"; + # }; + # archive = { + # zfs_type = "filesystem"; + # mountpoint = "/archive"; + # options.compression = "zstd"; + # options."com.sun:auto-snapshot" = "true"; + # }; + # zfs_unmounted_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "none"; + # }; + # zfs_legacy_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "legacy"; + # mountpoint = "/zfs_legacy_fs"; + # }; + # zfs_testvolume = { + # zfs_type = "volume"; + # size = "10M"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/ext4onzfs"; + # }; + # }; + # encrypted = { + # zfs_type = "filesystem"; + # size = "20M"; + # options = { + # mountpoint = "none"; + # encryption = "aes-256-gcm"; + # keyformat = "passphrase"; + # keylocation = "file:///tmp/secret.key"; + # }; + # }; + # "encrypted/test" = { + # zfs_type = "filesystem"; + # size = "2M"; + # mountpoint = "/zfs_crypted"; + # }; }; }; }; From b1b5e77f47f30987dde168c6a7757508ca6fa719 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:22:24 -0500 Subject: [PATCH 204/391] back to disko module once again --- hosts/swan/default.nix | 2 +- hosts/swan/disks.nix | 326 +++++++++++++++++++++-------------------- 2 files changed, 165 insertions(+), 163 deletions(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 4be4e43..ba632f0 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,6 +10,7 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix + ./disks.nix ../../modules/common ../../modules/nixos (removeAttrs globals [ "mail.server" ]) @@ -17,7 +18,6 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager disko.nixosModules.disko { - disko.devices = import ./disks.nix; server = true; gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index cccf648..ffa1155 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -1,166 +1,168 @@ -{ - disk = { - boot = { - type = "disk"; - device = "/dev/nvme0n1"; - content = { - type = "table"; - format = "gpt"; - partitions = [ - { - type = "partition"; - name = "ESP"; - start = "0"; - end = "512MiB"; - fs-type = "fat32"; - bootable = true; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - }; - } - { - type = "partition"; - name = "root"; - start = "512MiB"; - end = "100%"; - part-type = "primary"; - bootable = true; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - } - ]; - }; - }; - sda = { - type = "disk"; - device = "/dev/sda"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - sdb = { - type = "disk"; - device = "/dev/sdb"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - sdc = { - type = "disk"; - device = "/dev/sdc"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - }; - zpool = { - tank = { - type = "zpool"; - mode = "raidz1"; - rootFsOptions = { - compression = "on"; # lz4 by default - "com.sun:auto-snapshot" = "false"; - ashift = 12; - }; - # mountpoint = "/"; - - datasets = { - media = { - zfs_type = "filesystem"; - mountpoint = "none"; - options."com.sun:auto-snapshot" = "false"; +{ ... }: { + disko.devices = { + disk = { + boot = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + type = "partition"; + name = "root"; + start = "512MiB"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + } + ]; + }; + }; + sda = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + sdb = { + type = "disk"; + device = "/dev/sdb"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + sdc = { + type = "disk"; + device = "/dev/sdc"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + }]; + }; + }; + }; + zpool = { + tank = { + type = "zpool"; + mode = "raidz1"; + rootFsOptions = { + compression = "on"; # lz4 by default + "com.sun:auto-snapshot" = "false"; + ashift = "12"; + }; + # mountpoint = "/"; + + datasets = { + media = { + zfs_type = "filesystem"; + mountpoint = "/media"; + options."com.sun:auto-snapshot" = "false"; + }; + # "media/movies" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/movies"; + # options.recordsize = "1M"; + # }; + # "media/tv" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/tv"; + # options.recordsize = "1M"; + # }; + # "media/books" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/books"; + # }; + # archive = { + # zfs_type = "filesystem"; + # mountpoint = "/archive"; + # options.compression = "zstd"; + # options."com.sun:auto-snapshot" = "true"; + # }; + # zfs_unmounted_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "none"; + # }; + # zfs_legacy_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "legacy"; + # mountpoint = "/zfs_legacy_fs"; + # }; + # zfs_testvolume = { + # zfs_type = "volume"; + # size = "10M"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/ext4onzfs"; + # }; + # }; + # encrypted = { + # zfs_type = "filesystem"; + # size = "20M"; + # options = { + # mountpoint = "none"; + # encryption = "aes-256-gcm"; + # keyformat = "passphrase"; + # keylocation = "file:///tmp/secret.key"; + # }; + # }; + # "encrypted/test" = { + # zfs_type = "filesystem"; + # size = "2M"; + # mountpoint = "/zfs_crypted"; + # }; }; - # "media/movies" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/movies"; - # options.recordsize = "1M"; - # }; - # "media/tv" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/tv"; - # options.recordsize = "1M"; - # }; - # "media/books" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/books"; - # }; - # archive = { - # zfs_type = "filesystem"; - # mountpoint = "/archive"; - # options.compression = "zstd"; - # options."com.sun:auto-snapshot" = "true"; - # }; - # zfs_unmounted_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "none"; - # }; - # zfs_legacy_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "legacy"; - # mountpoint = "/zfs_legacy_fs"; - # }; - # zfs_testvolume = { - # zfs_type = "volume"; - # size = "10M"; - # content = { - # type = "filesystem"; - # format = "ext4"; - # mountpoint = "/ext4onzfs"; - # }; - # }; - # encrypted = { - # zfs_type = "filesystem"; - # size = "20M"; - # options = { - # mountpoint = "none"; - # encryption = "aes-256-gcm"; - # keyformat = "passphrase"; - # keylocation = "file:///tmp/secret.key"; - # }; - # }; - # "encrypted/test" = { - # zfs_type = "filesystem"; - # size = "2M"; - # mountpoint = "/zfs_crypted"; - # }; }; }; }; From c360460d806c3d072901e44cc10fae745adccb65 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:32:54 -0500 Subject: [PATCH 205/391] add filesystem labels to disko config --- hosts/swan/disks.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index ffa1155..95e2667 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -19,6 +19,7 @@ type = "filesystem"; format = "vfat"; mountpoint = "/boot"; + extraArgs = "--label boot"; }; } { @@ -32,6 +33,7 @@ type = "filesystem"; format = "ext4"; mountpoint = "/"; + extraArgs = "--label nixos"; }; } ]; From 60b68785a90afe647acc72e94f58065bc0c67f74 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:35:56 -0500 Subject: [PATCH 206/391] fix: types --- hosts/swan/disks.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index 95e2667..eee1302 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -19,7 +19,7 @@ type = "filesystem"; format = "vfat"; mountpoint = "/boot"; - extraArgs = "--label boot"; + extraArgs = [ "--label boot" ]; }; } { @@ -33,7 +33,7 @@ type = "filesystem"; format = "ext4"; mountpoint = "/"; - extraArgs = "--label nixos"; + extraArgs = [ "--label nixos" ]; }; } ]; From 08716d1c980b0557d03f5bc08d0f62d0242114fb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:37:28 -0500 Subject: [PATCH 207/391] fix: label syntax --- hosts/swan/disks.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index eee1302..dcc5e31 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -19,7 +19,7 @@ type = "filesystem"; format = "vfat"; mountpoint = "/boot"; - extraArgs = [ "--label boot" ]; + extraArgs = [ "-n boot" ]; }; } { @@ -33,7 +33,7 @@ type = "filesystem"; format = "ext4"; mountpoint = "/"; - extraArgs = [ "--label nixos" ]; + extraArgs = [ "-L nixos" ]; }; } ]; From 30fe7c2d1837a3a286f5965b3eb2622308616714 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:53:45 -0500 Subject: [PATCH 208/391] disable disko enforcement --- hosts/swan/disks.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix index dcc5e31..4a99796 100644 --- a/hosts/swan/disks.nix +++ b/hosts/swan/disks.nix @@ -1,4 +1,5 @@ { ... }: { + disko.enableConfig = false; disko.devices = { disk = { boot = { From d56a48cf65585add4e7bcd29ee0609ff2ea73db8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:22:31 -0500 Subject: [PATCH 209/391] add zfs module with options --- hosts/swan/default.nix | 7 ++++--- modules/nixos/hardware/default.nix | 1 + modules/nixos/hardware/zfs.nix | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 modules/nixos/hardware/zfs.nix diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index ba632f0..c207deb 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -19,6 +19,7 @@ nixpkgs.lib.nixosSystem { disko.nixosModules.disko { server = true; + zfs.enable = true; gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; @@ -36,9 +37,9 @@ nixpkgs.lib.nixosSystem { neovim.enable = true; - boot.zfs.enabled = true; - boot.kernelPackages = - config.boot.zfs.package.latestCompatibleLinuxPackages; + # boot.zfs.enabled = true; + # boot.kernelPackages = + # config.boot.zfs.package.latestCompatibleLinuxPackages; # boot.zfs.extraPools = [ "mypool" ]; # services.zfs.autoScrub.enable = true; # services.zfs.autoScrub.interval = "daily"; diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 8dd57a5..6d3f9f0 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -10,6 +10,7 @@ ./server.nix ./sleep.nix ./wifi.nix + ./zfs.nix ]; options = { diff --git a/modules/nixos/hardware/zfs.nix b/modules/nixos/hardware/zfs.nix new file mode 100644 index 0000000..07b82ea --- /dev/null +++ b/modules/nixos/hardware/zfs.nix @@ -0,0 +1,14 @@ +{ config, pkgs, lib, ... }: { + + options = { zfs.enable = lib.mkEnableOption "ZFS file system."; }; + + config = + lib.mkIf (pkgs.stdenv.isLinux && config.server && config.zfs.enable) { + + # Only use compatible Linux kernel, since ZFS can be behind + boot.kernelPackages = + config.boot.zfs.package.latestCompatibleLinuxPackages; + + }; + +} From fb74122458249dcf0fb653427a303ab20123f6b3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:23:26 -0500 Subject: [PATCH 210/391] fix hardware-configuration for swan --- hosts/swan/hardware-configuration.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hosts/swan/hardware-configuration.nix b/hosts/swan/hardware-configuration.nix index bcf62c3..f8d211c 100644 --- a/hosts/swan/hardware-configuration.nix +++ b/hosts/swan/hardware-configuration.nix @@ -12,6 +12,16 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "vfat"; + }; + swapDevices = [ ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking From e6456d7f02b1b750dbfc444ebd63ab214bbff7e7 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:25:20 -0500 Subject: [PATCH 211/391] ssh settings for sshd --- modules/nixos/services/sshd.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/nixos/services/sshd.nix b/modules/nixos/services/sshd.nix index 229a21c..825a9ee 100644 --- a/modules/nixos/services/sshd.nix +++ b/modules/nixos/services/sshd.nix @@ -17,11 +17,13 @@ services.openssh = { enable = true; ports = [ 22 ]; - passwordAuthentication = false; - gatewayPorts = "no"; - forwardX11 = false; allowSFTP = true; - permitRootLogin = config.permitRootLogin; + settings = { + GatewayPorts = "no"; + X11Forwarding = false; + PasswordAuthentication = false; + PermitRootLogin = config.permitRootLogin; + }; }; users.users.${config.user}.openssh.authorizedKeys.keys = From ab6a339c34ee3db463e9611efb79b4c05d2704b8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:30:41 -0500 Subject: [PATCH 212/391] try to force https for dotfiles clone git seems to fail with ssh, at least to github --- modules/common/repositories/dotfiles.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/common/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix index edfdc5d..d2fcf62 100644 --- a/modules/common/repositories/dotfiles.nix +++ b/modules/common/repositories/dotfiles.nix @@ -14,6 +14,10 @@ [ "writeBoundary" ] '' if [ ! -d "${config.dotfilesPath}" ]; then $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") + + # Force HTTPS because anonymous SSH doesn't work + GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf"; + $DRY_RUN_CMD ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" fi ''; From 3689f8ef528e1026afa6f5a3e49f62a342aee25a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:40:24 -0500 Subject: [PATCH 213/391] try to force https in single command --- modules/common/repositories/dotfiles.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/common/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix index d2fcf62..c7f03ba 100644 --- a/modules/common/repositories/dotfiles.nix +++ b/modules/common/repositories/dotfiles.nix @@ -16,9 +16,7 @@ $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") # Force HTTPS because anonymous SSH doesn't work - GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf"; - - $DRY_RUN_CMD ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" + $DRY_RUN_CMD GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" fi ''; From 595a02383e7be0118807354f34eaa030ff975192 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:45:40 -0500 Subject: [PATCH 214/391] use multiple env variables to force git https --- modules/common/repositories/dotfiles.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/common/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix index c7f03ba..5f7ce27 100644 --- a/modules/common/repositories/dotfiles.nix +++ b/modules/common/repositories/dotfiles.nix @@ -16,7 +16,11 @@ $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") # Force HTTPS because anonymous SSH doesn't work - $DRY_RUN_CMD GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" + GIT_CONFIG_COUNT=1 \ + GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" \ + GIT_CONFIG_VALUE_0="git@github.com:" \ + $DRY_RUN_CMD \ + ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}" fi ''; From 640e447006ba19abdad72442e89c71ece968bd49 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Feb 2023 13:21:50 -0500 Subject: [PATCH 215/391] replace sumneko_lua with lua_ls still the same program, but moved to new repository --- modules/common/neovim/config/lsp.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/common/neovim/config/lsp.nix b/modules/common/neovim/config/lsp.nix index 39b8421..0a22a11 100644 --- a/modules/common/neovim/config/lsp.nix +++ b/modules/common/neovim/config/lsp.nix @@ -6,10 +6,10 @@ pkgs.vimPlugins.null-ls-nvim ]; - use.lspconfig.sumneko_lua.setup = dsl.callWith { + use.lspconfig.lua_ls.setup = dsl.callWith { settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; }; capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; - cmd = [ "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" ]; + cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ]; }; use.lspconfig.nil_ls.setup = dsl.callWith { From 13014e6cc1ebf7515953678dfa96ed33aa83b8f9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 13:23:31 +0000 Subject: [PATCH 216/391] fix: fully enable zfs --- hosts/swan/default.nix | 4 ++++ modules/nixos/hardware/zfs.nix | 2 ++ 2 files changed, 6 insertions(+) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index c207deb..4a983c9 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -20,6 +20,10 @@ nixpkgs.lib.nixosSystem { { server = true; zfs.enable = true; + + # head -c 8 /etc/machine-id + networking.hostId = "600279f4"; # Random ID required for ZFS + gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; diff --git a/modules/nixos/hardware/zfs.nix b/modules/nixos/hardware/zfs.nix index 07b82ea..dea9c42 100644 --- a/modules/nixos/hardware/zfs.nix +++ b/modules/nixos/hardware/zfs.nix @@ -8,6 +8,8 @@ # Only use compatible Linux kernel, since ZFS can be behind boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + boot.kernelParams = [ "nohibernate" ]; + boot.supportedFilesystems = [ "zfs" ]; }; From fea0396dce602b4f675171769ba18db08ad569b4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 10:11:33 -0500 Subject: [PATCH 217/391] get neovim added to install-iso --- generators/staff/default.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/generators/staff/default.nix b/generators/staff/default.nix index dc43df4..904905c 100644 --- a/generators/staff/default.nix +++ b/generators/staff/default.nix @@ -1,7 +1,7 @@ # The Staff # ISO configuration for my USB drive -{ inputs, system, ... }: +{ inputs, system, overlays, ... }: with inputs; @@ -9,6 +9,7 @@ nixos-generators.nixosGenerate { inherit system; format = "install-iso"; modules = [{ + nixpkgs.overlays = overlays; networking.hostName = "staff"; users.extraUsers.root.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s" @@ -25,11 +26,22 @@ nixos-generators.nixosGenerate { }; }; environment.systemPackages = - with (import inputs.nixpkgs { inherit system; }); [ + let pkgs = import inputs.nixpkgs { inherit system overlays; }; + in with pkgs; [ git vim wget curl + (import ../../modules/common/neovim/package { + inherit pkgs; + # colors = import ../../colorscheme/gruvbox.dark.neovimConfig { + # inherit pkgs; + # }; + }) ]; + nix.extraOptions = '' + experimental-features = nix-command flakes + warn-dirty = false + ''; }]; } From afa62c5510902a2f0727de06d778db53feefb4b5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 10:42:11 -0500 Subject: [PATCH 218/391] fix: diskoConfigurations using nixos module --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 97725dd..c6e45a0 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,9 @@ darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; - diskoConfigurations = { swan = import ./hosts/swan/disks.nix; }; + diskoConfigurations = { + swan = { ... }: (import ./hosts/swan/disks.nix { }).disko.devices; + }; # Package servers into images with a generator packages = forAllSystems (system: { From 3fe6911e2d503e4fd83271a7e88d44c2236cf678 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 10:55:36 -0500 Subject: [PATCH 219/391] add separate root nix disko config --- disks/root.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 1 + 2 files changed, 45 insertions(+) create mode 100644 disks/root.nix diff --git a/disks/root.nix b/disks/root.nix new file mode 100644 index 0000000..75c70f3 --- /dev/null +++ b/disks/root.nix @@ -0,0 +1,44 @@ +{ disks, ... }: { + disk = { + boot = { + type = "disk"; + device = builtins.elemAt disks 0; + content = { + type = "table"; + format = "gpt"; + partitions = [ + # Boot partition + { + type = "partition"; + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + extraArgs = [ "-n boot" ]; + }; + } + # Root partition ext4 + { + type = "partition"; + name = "root"; + start = "512MiB"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + extraArgs = [ "-L nixos" ]; + }; + } + ]; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index c6e45a0..7f851c3 100644 --- a/flake.nix +++ b/flake.nix @@ -153,6 +153,7 @@ }; diskoConfigurations = { + root = import ./disks/root.nix; swan = { ... }: (import ./hosts/swan/disks.nix { }).disko.devices; }; From cb6054298041490c1347c4dab357e1ee4970c53f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:53:51 -0500 Subject: [PATCH 220/391] refactor apps and separate disko disks format-root app still not working --- apps/default.nix | 52 +++++---------------------- apps/format-root.nix | 39 ++++++++++++++++++++ apps/help.nix | 23 ++++++++++++ apps/neovim.nix | 13 +++++++ apps/rebuild.nix | 15 ++++++++ disks/root.nix | 2 +- flake.nix | 16 ++++++--- hosts/swan/default.nix | 7 +++- hosts/swan/hardware-configuration.nix | 18 +++++----- 9 files changed, 125 insertions(+), 60 deletions(-) create mode 100644 apps/format-root.nix create mode 100644 apps/help.nix create mode 100644 apps/neovim.nix create mode 100644 apps/rebuild.nix diff --git a/apps/default.nix b/apps/default.nix index 0d1f1d0..659628c 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -1,45 +1,19 @@ { pkgs, ... }: rec { - default = { - type = "app"; - program = builtins.toString (pkgs.writeShellScript "default" '' - ${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options" - ${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.' - echo "" - echo "" - ${pkgs.gum}/bin/gum format --type=template -- \ - ' • {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \ - ' • {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \ - ' • {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \ - ' • {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \ - ' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \ - ' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \ - ' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \ - ' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}' - echo "" - echo "" - ''); - }; + # Show quick helper + default = import ./help.nix { inherit pkgs; }; - # Format and install from nothing + # Format primary disk + format-root = import ./format-root.nix { inherit pkgs; }; + + # Format and install from nothing (deprecated) installer = import ./installer.nix { inherit pkgs; }; # Display the readme for this repository readme = import ./readme.nix { inherit pkgs; }; # Rebuild - rebuild = { - type = "app"; - program = builtins.toString (pkgs.writeShellScript "rebuild" '' - echo ${pkgs.system} - SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"} - if [ "$SYSTEM" == "darwin" ]; then - darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass - else - nixos-rebuild switch --flake github:nmasur/dotfiles - fi - ''); - }; + rebuild = import ./rebuild.nix { inherit pkgs; }; # Load the SSH key for this machine loadkey = import ./loadkey.nix { inherit pkgs; }; @@ -54,17 +28,7 @@ netdata = import ./netdata-cloud.nix { inherit pkgs; }; # Run neovim as an app - neovim = { - type = "app"; - program = "${ - (import ../modules/common/neovim/package { - inherit pkgs; - colors = - import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; }; - }) - }/bin/nvim"; - }; - + neovim = import ./neovim.nix { inherit pkgs; }; nvim = neovim; } diff --git a/apps/format-root.nix b/apps/format-root.nix new file mode 100644 index 0000000..53200c5 --- /dev/null +++ b/apps/format-root.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: { + + # This script will partition and format drives; use at your own risk! + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "format-root" '' + set -e + + DISK=$1 + + if [ -z "''${DISK}" ]; then + ${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \ + --foreground "#fb4934" \ + "Missing required parameter." \ + "Usage: format-root -- " \ + "Flake example: nix run github:nmasur/dotfiles#format-root -- nvme0n1" + echo "(exiting)" + exit 1 + fi + + ${pkgs.disko-packaged}/bin/disko \ + --mode create \ + --dry-run \ + --flake "path:$(pwd)#root" \ + --arg disks '[ "/dev/$DISK" ]' + + ${pkgs.gum}/bin/gum confirm \ + "This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \ + --default=false + + ${pkgs.disko-packaged}/bin/disko \ + --mode create \ + --flake "path:$(pwd)#root" \ + --arg disks '[ '"/dev/$DISK"' ]' + + ''); + +} diff --git a/apps/help.nix b/apps/help.nix new file mode 100644 index 0000000..cb31b37 --- /dev/null +++ b/apps/help.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "default" '' + ${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options" + ${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.' + echo "" + echo "" + ${pkgs.gum}/bin/gum format --type=template -- \ + ' • {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \ + ' • {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \ + ' • {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \ + ' • {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \ + ' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \ + ' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \ + ' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \ + ' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}' + echo "" + echo "" + ''); + +} diff --git a/apps/neovim.nix b/apps/neovim.nix new file mode 100644 index 0000000..60fd389 --- /dev/null +++ b/apps/neovim.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: { + + type = "app"; + + program = "${ + (import ../modules/common/neovim/package { + inherit pkgs; + colors = + import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; }; + }) + }/bin/nvim"; + +} diff --git a/apps/rebuild.nix b/apps/rebuild.nix new file mode 100644 index 0000000..9d04bdb --- /dev/null +++ b/apps/rebuild.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + + type = "app"; + + program = builtins.toString (pkgs.writeShellScript "rebuild" '' + echo ${pkgs.system} + SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"} + if [ "$SYSTEM" == "darwin" ]; then + darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass + else + nixos-rebuild switch --flake github:nmasur/dotfiles + fi + ''); + +} diff --git a/disks/root.nix b/disks/root.nix index 75c70f3..b64df37 100644 --- a/disks/root.nix +++ b/disks/root.nix @@ -1,4 +1,4 @@ -{ disks, ... }: { +{ disks ? [ ], ... }: { disk = { boot = { type = "disk"; diff --git a/flake.nix b/flake.nix index 7f851c3..93035b8 100644 --- a/flake.nix +++ b/flake.nix @@ -152,10 +152,8 @@ darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; - diskoConfigurations = { - root = import ./disks/root.nix; - swan = { ... }: (import ./hosts/swan/disks.nix { }).disko.devices; - }; + # Disk formatting + diskoConfigurations = { root = import ./disks/root.nix; }; # Package servers into images with a generator packages = forAllSystems (system: { @@ -181,7 +179,15 @@ }); apps = forAllSystems (system: - let pkgs = import nixpkgs { inherit system overlays; }; + let + pkgs = import nixpkgs { + inherit system; + overlays = overlays ++ [ + (final: prev: { + disko-packaged = inputs.disko.packages.${system}.disko; + }) + ]; + }; in import ./apps { inherit pkgs; }); devShells = forAllSystems (system: diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 4a983c9..fe1e67f 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -10,7 +10,6 @@ nixpkgs.lib.nixosSystem { specialArgs = { }; modules = [ ./hardware-configuration.nix - ./disks.nix ../../modules/common ../../modules/nixos (removeAttrs globals [ "mail.server" ]) @@ -21,6 +20,12 @@ nixpkgs.lib.nixosSystem { server = true; zfs.enable = true; + disko = { + enableConfig = true; + devices.disks = + import ../../disks/root.nix { disks = [ "/dev/nvme0n1" ]; }; + }; + # head -c 8 /etc/machine-id networking.hostId = "600279f4"; # Random ID required for ZFS diff --git a/hosts/swan/hardware-configuration.nix b/hosts/swan/hardware-configuration.nix index f8d211c..63b8a61 100644 --- a/hosts/swan/hardware-configuration.nix +++ b/hosts/swan/hardware-configuration.nix @@ -12,15 +12,15 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-label/boot"; - fsType = "vfat"; - }; + # fileSystems."/" = { + # device = "/dev/disk/by-label/nixos"; + # fsType = "ext4"; + # }; + # + # fileSystems."/boot" = { + # device = "/dev/disk/by-label/boot"; + # fsType = "vfat"; + # }; swapDevices = [ ]; From 44821ea344b9083764f3f8896ec09cc8296454cc Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:03:39 -0500 Subject: [PATCH 221/391] fix disko partition for single disk --- apps/format-root.nix | 4 ++-- disks/root.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/format-root.nix b/apps/format-root.nix index 53200c5..c7449b4 100644 --- a/apps/format-root.nix +++ b/apps/format-root.nix @@ -23,7 +23,7 @@ --mode create \ --dry-run \ --flake "path:$(pwd)#root" \ - --arg disks '[ "/dev/$DISK" ]' + --arg disk \""/dev/''${DISK}"\" ${pkgs.gum}/bin/gum confirm \ "This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \ @@ -32,7 +32,7 @@ ${pkgs.disko-packaged}/bin/disko \ --mode create \ --flake "path:$(pwd)#root" \ - --arg disks '[ '"/dev/$DISK"' ]' + --arg disk "/dev/''${DISK}" ''); diff --git a/disks/root.nix b/disks/root.nix index b64df37..c622b97 100644 --- a/disks/root.nix +++ b/disks/root.nix @@ -1,8 +1,8 @@ -{ disks ? [ ], ... }: { +{ disk, ... }: { disk = { boot = { type = "disk"; - device = builtins.elemAt disks 0; + device = disk; content = { type = "table"; format = "gpt"; From aa4dc4a0c2ac5b37412dfe1fea12363731d1ffea Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:24:12 -0500 Subject: [PATCH 222/391] fix: disko root now takes one disk --- hosts/swan/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index fe1e67f..bc8c275 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -22,8 +22,7 @@ nixpkgs.lib.nixosSystem { disko = { enableConfig = true; - devices.disks = - import ../../disks/root.nix { disks = [ "/dev/nvme0n1" ]; }; + devices.disks = import ../../disks/root.nix { disk = "/dev/nvme0n1"; }; }; # head -c 8 /etc/machine-id From 2c310fd2f218561129ad22346a509abd1d512ee0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:28:10 -0500 Subject: [PATCH 223/391] fix: disko doesn't have disks attribute --- hosts/swan/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index bc8c275..b71923d 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -22,7 +22,7 @@ nixpkgs.lib.nixosSystem { disko = { enableConfig = true; - devices.disks = import ../../disks/root.nix { disk = "/dev/nvme0n1"; }; + devices = import ../../disks/root.nix { disk = "/dev/nvme0n1"; }; }; # head -c 8 /etc/machine-id From de1fae2baf9f8ed7406f75989754fe7f345377b5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 27 Feb 2023 01:49:46 +0000 Subject: [PATCH 224/391] setup but don't use generic zfs config --- disks/zfs.nix | 95 +++++++++++++++++++++++ hosts/swan/default.nix | 6 +- hosts/swan/disks.nix | 172 ----------------------------------------- 3 files changed, 100 insertions(+), 173 deletions(-) create mode 100644 disks/zfs.nix delete mode 100644 hosts/swan/disks.nix diff --git a/disks/zfs.nix b/disks/zfs.nix new file mode 100644 index 0000000..7181f4d --- /dev/null +++ b/disks/zfs.nix @@ -0,0 +1,95 @@ +{ pool, disks, ... }: { + disk = lib.genAttrs disks (disk: { + "${disk}" = { + type = "disk"; + device = "/dev/${disk}"; + content = { + type = "table"; + format = "gpt"; + partitions = [{ + type = "partition"; + name = "zfs"; + start = "128MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = pool; + }; + }]; + }; + }; + }); + zpool = { + "${pool}" = { + type = "zpool"; + mode = "raidz1"; + rootFsOptions = { + compression = "on"; # lz4 by default + "com.sun:auto-snapshot" = "false"; + ashift = "12"; + }; + # mountpoint = "/"; + + datasets = { + root = { + zfs_type = "filesystem"; + mountpoint = null; + options."com.sun:auto-snapshot" = "false"; + }; + # "media/movies" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/movies"; + # options.recordsize = "1M"; + # }; + # "media/tv" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/tv"; + # options.recordsize = "1M"; + # }; + # "media/books" = { + # zfs_type = "filesystem"; + # mountpoint = "/media/books"; + # }; + # archive = { + # zfs_type = "filesystem"; + # mountpoint = "/archive"; + # options.compression = "zstd"; + # options."com.sun:auto-snapshot" = "true"; + # }; + # zfs_unmounted_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "none"; + # }; + # zfs_legacy_fs = { + # zfs_type = "filesystem"; + # options.mountpoint = "legacy"; + # mountpoint = "/zfs_legacy_fs"; + # }; + # zfs_testvolume = { + # zfs_type = "volume"; + # size = "10M"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/ext4onzfs"; + # }; + # }; + # encrypted = { + # zfs_type = "filesystem"; + # size = "20M"; + # options = { + # mountpoint = "none"; + # encryption = "aes-256-gcm"; + # keyformat = "passphrase"; + # keylocation = "file:///tmp/secret.key"; + # }; + # }; + # "encrypted/test" = { + # zfs_type = "filesystem"; + # size = "2M"; + # mountpoint = "/zfs_crypted"; + # }; + }; + }; + }; +} diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index b71923d..91e2e23 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -22,7 +22,11 @@ nixpkgs.lib.nixosSystem { disko = { enableConfig = true; - devices = import ../../disks/root.nix { disk = "/dev/nvme0n1"; }; + devices = (import ../../disks/root.nix { disk = "/dev/nvme0n1"; }); + # // (import ../../disks/zfs.nix { + # pool = "tank"; + # disks = [ "/dev/sda" "/dev/sdb" "/dev/sdc" ]; + # }); }; # head -c 8 /etc/machine-id diff --git a/hosts/swan/disks.nix b/hosts/swan/disks.nix deleted file mode 100644 index 4a99796..0000000 --- a/hosts/swan/disks.nix +++ /dev/null @@ -1,172 +0,0 @@ -{ ... }: { - disko.enableConfig = false; - disko.devices = { - disk = { - boot = { - type = "disk"; - device = "/dev/nvme0n1"; - content = { - type = "table"; - format = "gpt"; - partitions = [ - { - type = "partition"; - name = "ESP"; - start = "0"; - end = "512MiB"; - fs-type = "fat32"; - bootable = true; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - extraArgs = [ "-n boot" ]; - }; - } - { - type = "partition"; - name = "root"; - start = "512MiB"; - end = "100%"; - part-type = "primary"; - bootable = true; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - extraArgs = [ "-L nixos" ]; - }; - } - ]; - }; - }; - sda = { - type = "disk"; - device = "/dev/sda"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - sdb = { - type = "disk"; - device = "/dev/sdb"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - sdc = { - type = "disk"; - device = "/dev/sdc"; - content = { - type = "table"; - format = "gpt"; - partitions = [{ - type = "partition"; - name = "zfs"; - start = "128MiB"; - end = "100%"; - content = { - type = "zfs"; - pool = "tank"; - }; - }]; - }; - }; - }; - zpool = { - tank = { - type = "zpool"; - mode = "raidz1"; - rootFsOptions = { - compression = "on"; # lz4 by default - "com.sun:auto-snapshot" = "false"; - ashift = "12"; - }; - # mountpoint = "/"; - - datasets = { - media = { - zfs_type = "filesystem"; - mountpoint = "/media"; - options."com.sun:auto-snapshot" = "false"; - }; - # "media/movies" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/movies"; - # options.recordsize = "1M"; - # }; - # "media/tv" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/tv"; - # options.recordsize = "1M"; - # }; - # "media/books" = { - # zfs_type = "filesystem"; - # mountpoint = "/media/books"; - # }; - # archive = { - # zfs_type = "filesystem"; - # mountpoint = "/archive"; - # options.compression = "zstd"; - # options."com.sun:auto-snapshot" = "true"; - # }; - # zfs_unmounted_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "none"; - # }; - # zfs_legacy_fs = { - # zfs_type = "filesystem"; - # options.mountpoint = "legacy"; - # mountpoint = "/zfs_legacy_fs"; - # }; - # zfs_testvolume = { - # zfs_type = "volume"; - # size = "10M"; - # content = { - # type = "filesystem"; - # format = "ext4"; - # mountpoint = "/ext4onzfs"; - # }; - # }; - # encrypted = { - # zfs_type = "filesystem"; - # size = "20M"; - # options = { - # mountpoint = "none"; - # encryption = "aes-256-gcm"; - # keyformat = "passphrase"; - # keylocation = "file:///tmp/secret.key"; - # }; - # }; - # "encrypted/test" = { - # zfs_type = "filesystem"; - # size = "2M"; - # mountpoint = "/zfs_crypted"; - # }; - }; - }; - }; - }; -} From 5557065c8b554de788cea7157943c11cbd0c3b93 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 27 Feb 2023 02:50:24 +0000 Subject: [PATCH 225/391] rearrange swan settings --- hosts/swan/default.nix | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 91e2e23..73b8cfb 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -18,8 +18,12 @@ nixpkgs.lib.nixosSystem { disko.nixosModules.disko { server = true; - zfs.enable = true; + networking.hostName = "swan"; + # head -c 8 /etc/machine-id + networking.hostId = "600279f4"; # Random ID required for ZFS + + zfs.enable = true; disko = { enableConfig = true; devices = (import ../../disks/root.nix { disk = "/dev/nvme0n1"; }); @@ -28,18 +32,15 @@ nixpkgs.lib.nixosSystem { # disks = [ "/dev/sda" "/dev/sdb" "/dev/sdc" ]; # }); }; - - # head -c 8 /etc/machine-id - networking.hostId = "600279f4"; # Random ID required for ZFS + boot.zfs.extraPools = [ "tank" ]; gui.enable = false; theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; + neovim.enable = true; wsl.enable = false; caddy.enable = true; - networking.hostName = "swan"; - # Disable passwords, only use SSH key publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; @@ -47,15 +48,6 @@ nixpkgs.lib.nixosSystem { # Clone dotfiles dotfiles.enable = true; - neovim.enable = true; - - # boot.zfs.enabled = true; - # boot.kernelPackages = - # config.boot.zfs.package.latestCompatibleLinuxPackages; - # boot.zfs.extraPools = [ "mypool" ]; - # services.zfs.autoScrub.enable = true; - # services.zfs.autoScrub.interval = "daily"; - # services.nfs.server.enable = true; } From a7fe90b236251281e8cfbce75f81489726ba90ee Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Feb 2023 22:04:45 -0500 Subject: [PATCH 226/391] add swan public key --- private/backup.age | 19 +++++++++++-------- private/mailpass.age | 18 ++++++++++-------- private/nextcloud.age | 18 ++++++++++-------- private/password.sha512 | 12 +++++++++++- private/transmission.json.age | 19 +++++++++++-------- private/vaultwarden.age | 20 +++++++++++--------- private/wireguard.age | 18 ++++++++++-------- public-keys | 5 +++-- 8 files changed, 77 insertions(+), 52 deletions(-) diff --git a/private/backup.age b/private/backup.age index 0a9a7e8..3132b96 100644 --- a/private/backup.age +++ b/private/backup.age @@ -1,10 +1,13 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBmVEo2 -bExsZERhYi9vVXMxVThRK2w3dFR4UlZVcGlsWUFPM3pReTQwaW5ZCjQ5Z3g3amZC -bWUwWkdKTStVbFpwMmdwK3pQQU5CeE5tMVNHbXI1UkdCTFUKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIE9sTG1lOHIyVGdLNWtJRTZtdGNWWEFsTTJ5bE1HS1V2MEdKeGNN -WFMyV28KVlRHdDg5SGFadVlJempKWkp6eEp6TkhINnl0R0xDL0J0WXByclpFWE5I -VQotLS0gVVhaUDZLTy8xS3hKOVliSlpuTEY2Q2xOQUEvblBtUG9Vb0I5ZE1oOUZ1 -VQr18Jwx6XDa7bwq0QWT6NdIFzqNUHWhDyUvS9twncFsr0yEAUDQd2XLtE+Vc8T9 -Z7y/C8Ct5+duqd6YaeqROJz5zVj0NnI0lshirBl89PQWF9ihp4V4Hw== +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBkOVNs +NklGeTFxTTQzQ2t5WVUvVzREVnk3WjB0ZnUwdGo5Wk5Zc2RVeVJJCnBFbHcvUzdi +SG5xeTg2dU9oRUtiYXk3cERJOC9zbitrZ1hxZ0RJWDVYNmcKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIElNNkFMYkRoYXpPV1RtWEhrdUJCbXczd05tTG5QNi8wVktYQmZn +eTlWbTgKUVVrb21mTTNzZ1d6cE0yU2l4SVhqbkNyUEpLSHJyUEMyS1pLNGloTlpK +cwotPiBzc2gtZWQyNTUxOSBuanZYNUEgRU5LM2FKNEZ3Y1dDOW02VFU4bnNuZHpE +QzBLMlBhVnY3aGIrZDNhOUNWcwpSMHNsYTRlNFc5V0NsQ1h2VGFqUHNBVkxTVXdz +dGx6bWFwR1FFU2JNdmlBCi0tLSB6b3dpRmFURm0veFRFRitpbmZoOWJFcU8rbHJk +OXVIbGpUSWNFdWZmczVNCrodWjz8yVOdHHcVH9s2gOJfDrZFCP7L14RdGs9UW/Iw +JaJr5YblUiqTfKJiCN8dnCve3oCUlIY6K+yrBh5GaNbiwOgCzzZO5BGXEqoUSnux +ltmV1UI4 -----END AGE ENCRYPTED FILE----- diff --git a/private/mailpass.age b/private/mailpass.age index a8336c2..91ef825 100644 --- a/private/mailpass.age +++ b/private/mailpass.age @@ -1,10 +1,12 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBIRnEy -am1HTXptMmpSTjZQa2hQSUxNUU1rdXlod3U3bVZ0VGxQVlE2WldBClg0K3k5MDZH -NFlPdHI0VnZSZE9DTTNMeDdldUpFQ3V0V0k0RnRIZHFhdzAKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIFlxZFpqNU5kNVY2VUk0Um0zZ1d1M2FlRkYvV1BoTEFSNjZ2Vk9I -QTVHM0UKY2gvVU9wckVUNEFwdUwyVFJZUGwxOFFKYm12cUlFTEVrb3IvcXI3TnND -UQotLS0gMHdaajFjV2ozd0g5dWN5YkhiU2NBVWZVSU00aVIzY0VKYjJleVlQTUdX -QQo7rH6kOTRFP43U/qiBOCHx+hBGlaODFRS1CgzkuqfMOq8PM28RsIN+l3sbwjxE -W8chE/A0EChjIDtfYTMgsN3cYg== +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBsb0pX +R2RJRlJkbWF2a3BJN25ZY3ZwWTNRNDFhbWFkRE5TdkxDNUMrUms4CjI4TVN4Rk5U +a0xMRHVQSEJUcVJTQ2ZLd0c0c0MxM2thMFpyeXZ1NGM2NFEKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIFFnN1VkSzVXVzg4UGFWakxweWRmSldWbDBOMW9xYWJQek1Ielk0 +YXVrVFUKSzhUNVd3SGU4MkVZUXdLWXpFL3JCUWxOSitHOEJzQ0pXN0FKSXZ6RUFm +NAotPiBzc2gtZWQyNTUxOSBuanZYNUEgVG5jYmFCTkFmekJMdFBUVWJscmN5dUxp +RngzZEFEZUJINDBwUFBIUitpWQo3aWlLRDdoUklhbDlNeFJjeXFkTnJFcDJiV1Vv +ajBQQzFlaTFwWVFDSjljCi0tLSBWS3pzSWo4SXpIallxc0JQWk9LSWFDekxtOGRp +eGhYSEdqL1RmRnhtemMwCmQ5wc817Rk+Rs8RHXMe2Gm1mKbFOFMVrWFW5gLm9UHE +T05kZ7OBh34D9B7jmFokYM4uQBXBrydcb51TGVLXXgnN -----END AGE ENCRYPTED FILE----- diff --git a/private/nextcloud.age b/private/nextcloud.age index e0d8ca8..9bb5170 100644 --- a/private/nextcloud.age +++ b/private/nextcloud.age @@ -1,10 +1,12 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBudkxn -ZzU1YVViYUZBWVVTYm1SeHpvanQ5M0YwVGo2YldlN2RwY0tscWpBCjd0ZmtLZ2th -dEMrQk5QV0EzT0RpVkg5bGo1cHdTNzVYVkZpVzE4aHR0azgKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIFlqaEI2QUNnMjR1T0FENXJIMEJWOUFJUXZ4SlJxbUFnQktWUW9w -UFlmUUkKL1RwaWxoNFM4SkpadWtyN3JnWHdjVTYrQmo0dU9JUnp0MjN5enVsUm9o -ZwotLS0gWUd2eTR2VGkyeTZ5cHNuanMrSlZKVmc4T1ZORExmUnhDSjN0NEJkNjkz -cwriuyYCgvJe7TRi3n/JwxIRKMsoh7+xj4B5Fdxuj3BOtKVi1geSjlDHVklRwu9Y -IMCTLqQtj08JnuLfDezRGHAYCM8= +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBsWmI2 +UisyZ01rS3k4R0tJMThNdEZUOXZNVnV5RGNtVTR3V25wb2UwUDE0CnlGc0xySy8x +L2k2b1VRc1M0R1p5MkVTUWxHWkU2ZEtTSDFXK211V0ZHQTQKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIExWdlE1M1ZldnpPYWVta3ovdmdEU3VtZU0xWWFldnp3L3hicnFY +Y0dxQjQKdEFHa09Sd2IwUDRwM2dMK1paTFNESUJVRk1NNUFScXJGK1J5MkdtUGZv +YwotPiBzc2gtZWQyNTUxOSBuanZYNUEgVnRhWmtLTnpDSGhRODcvcUY1K2VySlJK +Rlk4WW1kQlVFd2Y4bWRLdGJWOAp1S1ZVclRrMUhicy9xQ1NTZ21tazEraDFaU2tD +eldWVVR1S1BTRDJ4ZjVrCi0tLSAwdXF6Nmt4RHBFVnVzZ08yeFBLbWF3dUx1M1hq +bVRzYmZiZk1Sb1ZOZUZRCpm4DLNa9DuoFQxQux3Q90PP6G30Z2b0j85cZqyr7anw +fg3687eKqMNwl4qdGYeE63oeUHrxfYISKB41zRDHmc7H2w== -----END AGE ENCRYPTED FILE----- diff --git a/private/password.sha512 b/private/password.sha512 index 354b39e..62e4517 100644 --- a/private/password.sha512 +++ b/private/password.sha512 @@ -1 +1,11 @@ -$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF. +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBJeUR3 +bVBwcXNpUDR0Uk84MTVLRGZqeTdLcDdCQ0lzeVA1aERmUmVzemd3CjFXMDBlaWF1 +ZWhBeU1BNm8yTTFBMGpzWXlmdzlRQW9TZE5qNnp3ZllYdUUKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIFBGdjZhNmVKQ1BVeG0zZ0ZoN2RDMHlYU3ZkZklkR1orVDJqOFBH +aXdRRTgKbk55RTBEZ3d3ZENrSW9qa2JMcWEwdzhjSzdqRnNSVi9NTWgzNjM0R0Qw +MAotPiBzc2gtZWQyNTUxOSBuanZYNUEgOVV4azZxLzE1NjBhZWpoNUtjTzFRb3lw +d01YNjdmZ3J6ZnVHZ2Q0akYxcwpqa1dNQkRxbnE1VEJuQkFlQ3kvS1o4cDlGblRX +bjVLbGJLcWZHZkhiakxjCi0tLSBoS1FDZXRUL0VMSkJsd3h4UzZMSTUrY0MvbUxU +UVpxUXFra1AxTkIrS3pJCgmERJeOqV69MGax3kihow5VXZfA8dQVc1zY5FOahCFK +-----END AGE ENCRYPTED FILE----- diff --git a/private/transmission.json.age b/private/transmission.json.age index 091ed0c..d247a49 100644 --- a/private/transmission.json.age +++ b/private/transmission.json.age @@ -1,10 +1,13 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBSYUU2 -OWp1ZDRLVTJrR1k3SVdXZnRPN3RUNDY5RFM2WEZaTzRmdU1zSWdrCjV1VHpNMG81 -VHA4LzdsN3FpOUNoTGNlWmlHS3E4dTVvWTVoZHJMSlNYTHMKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIDVjM1JmclgxQThKcU1XQWptWmN0MjlKU1NvMEpwMnYyd3Y4czBT -RTVkQ0UKc0pOYkRxZldsWnloQnBYMWk1eFU0M3R5SkZVTUYyaldIcENONE1PWVJv -NAotLS0gclZDQndaREZpZ2Z0R0d0alBPeW1tZFVOVHhSaHNlQTRXdTRoZmFDUFFK -SQqueOUzTFuhSryWW4Do+NAUcq2YdOtN8gmP5Zcp1oMe/9+JIs6Upjsc3eWn+dSA -7QwbGlTyd6D0+PLJxHA18Xfgpj5owGeTDtwykFPgdO1BjE8C3KlgzUfN +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyB1TWhO +N1k5bFFvODkwdzRGcGtFL2YzRkJDUjVSbUVFeXBOTExpK29uU2drCjN2cS9GZjJW +RGxrMlQzK3ZGVWU4L2M0M1d4cXJrOTNrcDhsdWUyRGt5N1EKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RICtoM2V3UjZ1cnVFN09pZ1Y0azYraENoWlN2ajRUeHRLZVlVd0Yw +T29BRW8Kb2ltQlpJZ1JUTkd6Wk14ZkFIdDliQ1JOMHMvVzhwaGkyMkl6ajFrYVNv +MAotPiBzc2gtZWQyNTUxOSBuanZYNUEgNThPSW91di91SWxtbTRpQVJwek94VGJV +UERvS2tITHF0SXVlVFEyLzJTMApuYjdsWndDd01mUk5LbXJWTkd6UEt3eFkvMk40 +VDBpZmk0bUkxNTBWMzlrCi0tLSBiVFpxcjd4ZkZ6YittMDBBT25rOFlrcEpTdXg1 +d2Y5TkdwZ25sRFN0ZjVzCj8h/4aeASCnUoK7Sc6LsY9ur3krKlF+3GMMvlLiRqsi +COBx+YbkwR0EfrxhLZ6DLHhM/t2jnWAMMzDK2a4volvQkdORLiRo3sfjR5kSy5N5 +Ml3lFlXKxYQ= -----END AGE ENCRYPTED FILE----- diff --git a/private/vaultwarden.age b/private/vaultwarden.age index 523b1bd..83bf3f6 100644 --- a/private/vaultwarden.age +++ b/private/vaultwarden.age @@ -1,11 +1,13 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBqNm0x -YVc0bXp6eldNdkp1QWk2cEI0WFBhVVd3cHhDODNwMS9UUTBPN25JCmxXZnRIcFZr -SFJrQnI3R1BTUk1BcVl3RjlUaXMzSXpqaGdTMi9reno1eHcKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIFlKWCtsWGtWdTI4L0ZFTVRHNFN5by9vTE95MXFoMVZGYlYrM1I2 -alREaE0Kd251SGRDdE96VmZqblhEWXFkZDhvRUZsZ1pnZ3NqdEdJSlBvaXhoOHVB -WQotLS0gaGJNRm14SkdXcTFmYlJUell1WUZUeEllT3ZwMkNaejF3eWJ5U1ZSdno1 -MAqQIT8vvUro+C+avm6lCPfrX9yigKzx/gtKfMB//1Ie7BUo1+o5iYoA+R0luMU8 -/zVX1yGAzDPqas/HfYclIPg3bdjm2dnpz0ltOrOvjA4x3nEzzrmS96zo3Fy1d8oX -oAMw2l/p2QDHI60cyhvC +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBLemo1 +TXRJdkYxR1RBcFdrVEthRUI1UEtWbm5LUlRKYVpOTUIyZjY2YlhJCmkzbEdmZFFN +MzBFQkN3ME9FcjdCOTN4T3ZlcWg1NEIydjZQQm93VURvcVEKLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIDNjMXpObEhuTWg5bitFL2VjUGtTcjhIMDYzeVFpQ0tpUnRRV3pJ +SGRwRzgKRkpzdzJsZ3N4dnhSaGplN0ZjQ1dpY0xOZHZyU0NON1NEbDc5MmtMKzhL +ZwotPiBzc2gtZWQyNTUxOSBuanZYNUEgaEFrMTZYNndKVWg0OTFtOVJyVTFPbjJJ +RHJwU0JsclUrSms5ckMyZTdoYwpmV3dlZFY4MEFYSEhoQnpic0NEd2xxOENIRTBt +MWs4RVNFUnIyTnNWUDRNCi0tLSAvT2ZPektwL2djUlNQdy9tek9hL3JmekJOc28z +NzU3cDR6TUxod0I5ODdZCnxOYrlDTdi8Y+m5PRxAYgS3u2cC1YlfXi5TZo1LIEjv +UxWwPwn8JAF9CYB1o8e6p/w+yMcUfr+2UHWo0GqLqye8VCGy7Vzk2S3tOCZJv+k9 ++kQtMva6CND8gBZIIJ3aXoYshT4sLWfx+BAkxPQ= -----END AGE ENCRYPTED FILE----- diff --git a/private/wireguard.age b/private/wireguard.age index 17f8112..c2e3a56 100644 --- a/private/wireguard.age +++ b/private/wireguard.age @@ -1,10 +1,12 @@ -----BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBOOXNm -VG5EMHhEU2JLbkYyY1VXdXZJd2VxSEVXUjZaaURnU254QUVzUENzCnhnV21oRFNY -NGpMeXlqdDlYRmltN1cxTlJ3eWFTVElpK0ZBalA3QVFoL2MKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIDk3TVhDVVBjQU5XNjVTbkxKdUNEU25uZXREeEpHcTF4STg4VXR1 -V2xzRTQKZTBXZUQrbjIwTDEwOEc3MktpQzBjTzhjS3lTNTJ0TEMyMVBOODQ0N0lt -OAotLS0gODA2L2FpSmxiWDAyM1IvM2Q4U2QrNmRkVjl1bFhURW5sNCtWZ2tiMnZU -YwoC0chavNt+a/AImm/7bNheZIPghrobp9g+ga+UpRWBtM2snpkyFZrBR0qAkw/f -3krp5Rrco7IOlEwWx96UzvAUpKlC7CdVI1MFa76ZUg== +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBqamNI +eGQ3Ty9td3owQWNyOXMrM1ZTQ1dSOVc0dEZ6UlplY0ZDQlV4MG1NCmQ1eUpTdURs +YkhsNnF5djkwdWRlcms4SFEyaTdFUFZ2WFpTaVRPRy8zam8KLT4gc3NoLWVkMjU1 +MTkgWXlTVU1RIHBTWEkyekhRQ1RqWnVpM2FQVGVqQzZyVFpuL0liZU9UUHl4dVpr +dno5UjgKbFZxL0xXTWZwYU0wWjNhYm9NZzVCRWhER2N6eWUySjV4N0c3Z3V4S2o2 +NAotPiBzc2gtZWQyNTUxOSBuanZYNUEgeDNtdjZvQkVGZXZsUFhkd3ZnWkNYaTdr +ZlFuR2RrNTVZNWh4WUY2cTh6OApEYTBwcGlvQ0xVazIzUjBBT2VuWGczRkRyM0d2 +YmdoMVRPMFh5NVBwb3RFCi0tLSBjaXVreU1LYjNvOVVZeTlTRldyWE02Rzc1V2xN +N082QUtDNXM2bEpRMlpjCp6Qtp6EN1L1V/mLp48M6uymwPmGjR1pAloYXDhXSiab +uz9LLBvB8qVp15/724DTLg6Mi72LVYiHZ+zQ3IB8kv7gjhMMryfFJSPErZfY -----END AGE ENCRYPTED FILE----- diff --git a/public-keys b/public-keys index 74beb04..29af5d8 100644 --- a/public-keys +++ b/public-keys @@ -1,4 +1,5 @@ # Scan hosts: ssh-keyscan -t ed25519 -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s noah -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHVknmPi7sG6ES0G0jcsvebzKGWWaMfJTYgvOue6EULI oracle.masu.rs +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s tempest +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHVknmPi7sG6ES0G0jcsvebzKGWWaMfJTYgvOue6EULI flame +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ9mwXlZnIALt9SnH3FOZvdgHLM5ZqwYUERXBbM7Rwh6 swan From ab9136af2c52ffa4043e19cade0d643b9088a49f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 28 Feb 2023 02:02:45 +0000 Subject: [PATCH 227/391] enable backups without any specific --- hosts/swan/default.nix | 6 ++++++ modules/nixos/services/backups.nix | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 73b8cfb..e459bb0 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -41,6 +41,12 @@ nixpkgs.lib.nixosSystem { wsl.enable = false; caddy.enable = true; + backup.s3 = { + endpoint = "s3.us-west-002.backblazeb2.com"; + bucket = "noahmasur-backup"; + accessKeyId = "0026b0e73b2e2c80000000005"; + }; + # Disable passwords, only use SSH key publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"; diff --git a/modules/nixos/services/backups.nix b/modules/nixos/services/backups.nix index 026325d..06496e4 100644 --- a/modules/nixos/services/backups.nix +++ b/modules/nixos/services/backups.nix @@ -27,7 +27,7 @@ users.groups.backup = { }; secrets.backup = { - source = ../../private/backup.age; + source = ../../../private/backup.age; dest = "${config.secretsDirectory}/backup"; group = "backup"; permissions = "0440"; @@ -38,6 +38,7 @@ services.litestream = { enable = true; environmentFile = config.secrets.backup.dest; + settings = { }; }; # Wait for secret to exist From 43343b2824089a484a448fac546ca6e3c8709cb7 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 28 Feb 2023 04:27:10 +0000 Subject: [PATCH 228/391] add jellyfin to swan --- hosts/flame/default.nix | 2 +- hosts/swan/default.nix | 2 +- modules/nixos/services/jellyfin.nix | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hosts/flame/default.nix b/hosts/flame/default.nix index 89db166..4eff655 100644 --- a/hosts/flame/default.nix +++ b/hosts/flame/default.nix @@ -29,7 +29,7 @@ nixpkgs.lib.nixosSystem { # FQDNs for various services networking.hostName = "flame"; bookServer = "books.masu.rs"; - streamServer = "stream.masu.rs"; + # streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; transmissionServer = "download.masu.rs"; metricsServer = "metrics.masu.rs"; diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index e459bb0..0228487 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -38,8 +38,8 @@ nixpkgs.lib.nixosSystem { theme = { colors = (import ../../colorscheme/gruvbox).dark; }; nixpkgs.overlays = overlays; neovim.enable = true; - wsl.enable = false; caddy.enable = true; + streamServer = "stream.masu.rs"; backup.s3 = { endpoint = "s3.us-west-002.backblazeb2.com"; diff --git a/modules/nixos/services/jellyfin.nix b/modules/nixos/services/jellyfin.nix index a870cdc..9ea1121 100644 --- a/modules/nixos/services/jellyfin.nix +++ b/modules/nixos/services/jellyfin.nix @@ -20,6 +20,9 @@ }]; }]; + # Grant user access to Jellyfin directories + users.users.${config.user}.extraGroups = [ "jellyfin" ]; + # Create videos directory, allow anyone in Jellyfin group to manage it systemd.tmpfiles.rules = [ "d /var/lib/jellyfin 0775 jellyfin jellyfin" From f648e92c285942fa6c6046742b489f471adc57b8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 28 Feb 2023 05:05:04 +0000 Subject: [PATCH 229/391] samba initial setup --- hosts/swan/default.nix | 1 + modules/common/applications/nautilus.nix | 3 +++ modules/nixos/services/default.nix | 1 + modules/nixos/services/samba.nix | 20 ++++++++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 modules/nixos/services/samba.nix diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 0228487..504e8af 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -40,6 +40,7 @@ nixpkgs.lib.nixosSystem { neovim.enable = true; caddy.enable = true; streamServer = "stream.masu.rs"; + samba.enable = true; backup.s3 = { endpoint = "s3.us-west-002.backblazeb2.com"; diff --git a/modules/common/applications/nautilus.nix b/modules/common/applications/nautilus.nix index d8610e6..1a9bcfb 100644 --- a/modules/common/applications/nautilus.nix +++ b/modules/common/applications/nautilus.nix @@ -17,6 +17,9 @@ gnome.sushi # Quick preview with spacebar ]; + # Allow browsing Samba shares + services.gvfs.enable = true; + # Set default for opening directories xdg.mimeApps.defaultApplications."inode/directory" = [ "nautilus.desktop" ]; diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index 9eb1d56..46f9ed7 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -15,6 +15,7 @@ ./netdata.nix ./nextcloud.nix ./prometheus.nix + ./samba.nix ./secrets.nix ./sshd.nix ./transmission.nix diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix new file mode 100644 index 0000000..7114b0a --- /dev/null +++ b/modules/nixos/services/samba.nix @@ -0,0 +1,20 @@ +{ config, lib, ... }: { + + options = { samba.enable = lib.mkEnableOption "Enable Samba sharing."; }; + + config = lib.mkIf (config.samba.enable) { + + services.samba.enable = true; + services.samba.shares.video = { + path = "/data/video"; + browseable = "yes"; + "read only" = "no"; + "guest ok" = "no"; + "force user" = config.user; + "force group" = config.user; + comment = "Movies and TV"; + }; + + }; + +} From 6e117769c6f3e500ea6a517819e9d64e6f891814 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 28 Feb 2023 00:11:59 -0500 Subject: [PATCH 230/391] fix: gvfs not in home-manager --- modules/common/applications/nautilus.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/common/applications/nautilus.nix b/modules/common/applications/nautilus.nix index 1a9bcfb..8d6c769 100644 --- a/modules/common/applications/nautilus.nix +++ b/modules/common/applications/nautilus.nix @@ -17,9 +17,6 @@ gnome.sushi # Quick preview with spacebar ]; - # Allow browsing Samba shares - services.gvfs.enable = true; - # Set default for opening directories xdg.mimeApps.defaultApplications."inode/directory" = [ "nautilus.desktop" ]; @@ -31,6 +28,10 @@ }; }; }; + + # Allow browsing Samba shares + services.gvfs.enable = true; + }; } From d37cabfd9af3bd417663511752b6fbab2177acc9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 28 Feb 2023 00:12:19 -0500 Subject: [PATCH 231/391] fix: don't age encrypt password hash --- hosts/hydra/default.nix | 2 +- hosts/tempest/default.nix | 2 +- password.sha512 | 1 + private/password.sha512 | 11 ----------- 4 files changed, 3 insertions(+), 13 deletions(-) create mode 100644 password.sha512 delete mode 100644 private/password.sha512 diff --git a/hosts/hydra/default.nix b/hosts/hydra/default.nix index 24006fe..e5013b9 100644 --- a/hosts/hydra/default.nix +++ b/hosts/hydra/default.nix @@ -25,7 +25,7 @@ nixpkgs.lib.nixosSystem { colors = (import ../../colorscheme/gruvbox).dark; dark = true; }; - passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; + passwordHash = nixpkgs.lib.fileContents ../../password.sha512; wsl = { enable = true; wslConf.automount.root = "/mnt"; diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix index 17eb7ad..36ba623 100644 --- a/hosts/tempest/default.nix +++ b/hosts/tempest/default.nix @@ -29,7 +29,7 @@ nixpkgs.lib.nixosSystem { }; wallpaper = "${wallpapers}/gruvbox/road.jpg"; gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark"; - passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512; + passwordHash = nixpkgs.lib.fileContents ../../password.sha512; wsl.enable = false; publicKey = null; diff --git a/password.sha512 b/password.sha512 new file mode 100644 index 0000000..354b39e --- /dev/null +++ b/password.sha512 @@ -0,0 +1 @@ +$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF. diff --git a/private/password.sha512 b/private/password.sha512 deleted file mode 100644 index 62e4517..0000000 --- a/private/password.sha512 +++ /dev/null @@ -1,11 +0,0 @@ ------BEGIN AGE ENCRYPTED FILE----- -YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IE1nSGFPdyBJeUR3 -bVBwcXNpUDR0Uk84MTVLRGZqeTdLcDdCQ0lzeVA1aERmUmVzemd3CjFXMDBlaWF1 -ZWhBeU1BNm8yTTFBMGpzWXlmdzlRQW9TZE5qNnp3ZllYdUUKLT4gc3NoLWVkMjU1 -MTkgWXlTVU1RIFBGdjZhNmVKQ1BVeG0zZ0ZoN2RDMHlYU3ZkZklkR1orVDJqOFBH -aXdRRTgKbk55RTBEZ3d3ZENrSW9qa2JMcWEwdzhjSzdqRnNSVi9NTWgzNjM0R0Qw -MAotPiBzc2gtZWQyNTUxOSBuanZYNUEgOVV4azZxLzE1NjBhZWpoNUtjTzFRb3lw -d01YNjdmZ3J6ZnVHZ2Q0akYxcwpqa1dNQkRxbnE1VEJuQkFlQ3kvS1o4cDlGblRX -bjVLbGJLcWZHZkhiakxjCi0tLSBoS1FDZXRUL0VMSkJsd3h4UzZMSTUrY0MvbUxU -UVpxUXFra1AxTkIrS3pJCgmERJeOqV69MGax3kihow5VXZfA8dQVc1zY5FOahCFK ------END AGE ENCRYPTED FILE----- From f5674134fcefbe3955e39394827635a03ebe9589 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 1 Mar 2023 04:54:48 +0000 Subject: [PATCH 232/391] add nextcloud to swan --- hosts/swan/default.nix | 1 + modules/nixos/services/nextcloud.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 504e8af..c55b470 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -40,6 +40,7 @@ nixpkgs.lib.nixosSystem { neovim.enable = true; caddy.enable = true; streamServer = "stream.masu.rs"; + nextcloudServer = "cloud.masu.rs"; samba.enable = true; backup.s3 = { diff --git a/modules/nixos/services/nextcloud.nix b/modules/nixos/services/nextcloud.nix index 3e997c0..8dee321 100644 --- a/modules/nixos/services/nextcloud.nix +++ b/modules/nixos/services/nextcloud.nix @@ -41,7 +41,7 @@ # Create credentials file for nextcloud secrets.nextcloud = { - source = ../../private/nextcloud.age; + source = ../../../private/nextcloud.age; dest = "${config.secretsDirectory}/nextcloud"; owner = "nextcloud"; group = "nextcloud"; From cdcc90f85d6f2ff0a191ecde5cb0c40d4a5ca013 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 28 Feb 2023 23:55:21 -0500 Subject: [PATCH 233/391] docs: restore litestream nextcloud backups --- docs/restore-nextcloud.md | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/restore-nextcloud.md diff --git a/docs/restore-nextcloud.md b/docs/restore-nextcloud.md new file mode 100644 index 0000000..ad9381d --- /dev/null +++ b/docs/restore-nextcloud.md @@ -0,0 +1,43 @@ +# Restoring Nextcloud From Backup + +Install the `litestream` package. + +``` +nix-shell --run fish -p litestream +``` + +Set the S3 credentials: + +``` +set -x AWS_ACCESS_KEY_ID (read) +set -x AWS_SECRET_ACCESS_KEY (read) +``` + +Restore from S3: + +``` +litestream restore -o nextcloud.db s3://noahmasur-backup.s3.us-west-002.backblazeb2.com/nextcloud +``` + +Install Nextcloud. Then copy DB: + +``` +sudo rm /var/lib/nextcloud/data/nextcloud.db* +sudo mv nextcloud.db /var/lib/nextcloud/data/ +sudo chown nextcloud:nextcloud /var/lib/nextcloud/data/nextcloud.db +sudo chmod 770 /var/lib/nextcloud/data/nextcloud.db +``` + +Restart Nextcloud: + +``` +sudo systemctl restart phpfpm-nextcloud.service +``` + +Adjust Permissions and Directories: + +``` +sudo mkdir /var/lib/nextcloud/data/noah/files +sudo chown nextcloud:nextcloud /var/lib/nextcloud/data/noah/files +``` + From d1f21ec8742cb21f1aeee80ad2832d20468a306a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 2 Mar 2023 14:47:51 -0500 Subject: [PATCH 234/391] fix: dismiss notifications with hammerspoon in ventura --- .../close_notifications.applescript | 19 +++++++++++++++++++ .../Spoons/DismissAlerts.spoon/init.lua | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript new file mode 100644 index 0000000..cd849a1 --- /dev/null +++ b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript @@ -0,0 +1,19 @@ +tell application "System Events" + try + set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter" + + repeat with _group in _groups + + set _actions to actions of _group + + repeat with _action in _actions + if description of _action is in {"Schlie§en", "Alle entfernen", "Close", "Clear All"} then + perform _action + + end if + end repeat + + end repeat + + end try +end tell diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua index f6a7aba..74ba8b9 100644 --- a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/init.lua @@ -10,7 +10,7 @@ obj.license = "MIT - https://opensource.org/licenses/MIT" function obj:init() hs.hotkey.bind({ "cmd", "alt", "ctrl" }, "k", function() - hs.osascript.javascriptFromFile("Spoons/DismissAlerts.spoon/close_notifications_applescript.js") + hs.osascript.applescriptFromFile("Spoons/DismissAlerts.spoon/close_notifications.applescript") end) end From ab6f80fc18e4116be0b1ab8404cf6b7528a2cb31 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 2 Mar 2023 14:48:49 -0500 Subject: [PATCH 235/391] overlay for age no longer needed --- modules/common/shell/utilities.nix | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/common/shell/utilities.nix b/modules/common/shell/utilities.nix index 4ffa962..6f2d1a4 100644 --- a/modules/common/shell/utilities.nix +++ b/modules/common/shell/utilities.nix @@ -17,20 +17,6 @@ in { home-manager.users.${config.user} = { - # Fix: age won't build - nixpkgs.overlays = [ - (_final: prev: { - age = prev.age.overrideAttrs (_old: { - src = prev.fetchFromGitHub { - owner = "FiloSottile"; - repo = "age"; - rev = "7354aa0d08a06eac42c635670a55f858bd23c943"; - sha256 = "H80mNTgZmExDMgubONIXP7jmLBvNMVqXee6NiZJhPFY="; - }; - }); - }) - ]; - home.packages = with pkgs; [ unzip # Extract zips rsync # Copy folders From 0ed11de17429f43e641d41a05cc2564dfad1cb04 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 2 Mar 2023 14:49:20 -0500 Subject: [PATCH 236/391] move gvfs outside of common nixos-only option --- modules/common/applications/nautilus.nix | 3 --- modules/nixos/services/samba.nix | 26 +++++++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/common/applications/nautilus.nix b/modules/common/applications/nautilus.nix index 8d6c769..4b8a142 100644 --- a/modules/common/applications/nautilus.nix +++ b/modules/common/applications/nautilus.nix @@ -29,9 +29,6 @@ }; }; - # Allow browsing Samba shares - services.gvfs.enable = true; - }; } diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix index 7114b0a..6c0fb7e 100644 --- a/modules/nixos/services/samba.nix +++ b/modules/nixos/services/samba.nix @@ -2,19 +2,25 @@ options = { samba.enable = lib.mkEnableOption "Enable Samba sharing."; }; - config = lib.mkIf (config.samba.enable) { + config = { - services.samba.enable = true; - services.samba.shares.video = { - path = "/data/video"; - browseable = "yes"; - "read only" = "no"; - "guest ok" = "no"; - "force user" = config.user; - "force group" = config.user; - comment = "Movies and TV"; + services.samba = lib.mkIf (config.samba.enable) { + enable = true; + shares.video = { + path = "/data/video"; + browseable = "yes"; + "read only" = "no"; + "guest ok" = "no"; + "force user" = config.user; + "force group" = config.user; + comment = "Movies and TV"; + }; }; + # Allow browsing Samba shares + services.gvfs = + lib.mkIf (config.gui.enable && config.nautilus.enable) { enable = true; }; + }; } From cda3ee0a4c93fea9a696e97f705ec06892fa43d8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:15:07 -0500 Subject: [PATCH 237/391] credit attribution to LaunchBar for applescript --- .../Spoons/DismissAlerts.spoon/close_notifications.applescript | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript index cd849a1..a5ec015 100644 --- a/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript +++ b/modules/darwin/hammerspoon/Spoons/DismissAlerts.spoon/close_notifications.applescript @@ -1,3 +1,5 @@ +# Credit: https://github.com/Ptujec/LaunchBar/blob/f7b5a0dba9919c2fec879513f68a044f78748539/Notifications/Dismiss%20all%20notifications.lbaction/Contents/Scripts/default.applescript + tell application "System Events" try set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter" From fb47302f3bced666b1821706320b15304b12178d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 3 Mar 2023 09:39:42 -0500 Subject: [PATCH 238/391] add cachix community binary cache --- modules/common/default.nix | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/common/default.nix b/modules/common/default.nix index ce4219a..1d04288 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -77,11 +77,28 @@ config = let stateVersion = "23.05"; in { - # Enable features in Nix commands - nix.extraOptions = '' - experimental-features = nix-command flakes - warn-dirty = false - ''; + nix = { + + # Enable features in Nix commands + extraOptions = '' + experimental-features = nix-command flakes + warn-dirty = false + ''; + + settings = { + + # Add community Cachix to binary cache + substituters = [ "https://nix-community.cachix.org" ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + + # Scans and hard links identical files in the store + auto-optimise-store = true; + + }; + + }; # Basic common system packages for all devices environment.systemPackages = with pkgs; [ git vim wget curl ]; From 366a7f6157953ad19ae2528636d228ef0081d2ae Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 3 Mar 2023 20:54:27 +0000 Subject: [PATCH 239/391] move nextcloud data directory --- modules/nixos/services/nextcloud.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/nixos/services/nextcloud.nix b/modules/nixos/services/nextcloud.nix index 8dee321..c6f6541 100644 --- a/modules/nixos/services/nextcloud.nix +++ b/modules/nixos/services/nextcloud.nix @@ -15,6 +15,7 @@ services.nextcloud = { enable = true; package = pkgs.nextcloud25; # Required to specify + datadir = "/data/nextcloud"; https = true; hostName = "localhost"; maxUploadSize = "50G"; @@ -52,6 +53,9 @@ before = [ "nextcloud-setup.service" ]; }; + # Grant user access to Nextcloud directories + users.users.${config.user}.extraGroups = [ "nextcloud" ]; + ## Backup config # Open to groups, allowing for backups From 7ab78767d4eadca1d74310082d3e5d89fe084ad5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 4 Mar 2023 01:04:02 +0000 Subject: [PATCH 240/391] move calibre books to zfs directory --- docs/restore-calibre.md | 23 ++++++++++++++ docs/restore-nextcloud.md | 12 ++++---- hosts/swan/default.nix | 1 + modules/nixos/services/calibre.nix | 48 ++++++++++++++++++------------ 4 files changed, 59 insertions(+), 25 deletions(-) create mode 100644 docs/restore-calibre.md diff --git a/docs/restore-calibre.md b/docs/restore-calibre.md new file mode 100644 index 0000000..01aa71a --- /dev/null +++ b/docs/restore-calibre.md @@ -0,0 +1,23 @@ +# Restoring Calibre From Backup + +The `metadata.db` holds the library and `app.db` and `gdrive.db` contain the +web/account information. + +Place books directories in `/data/books/`. + +Place `metadata.db` in `/var/lib/calibre-web-db/`. + +Symlink `metadata.db` to the library: + +``` +sudo ln -s /var/lib/calibre-web-db/metadata.db /data/books/metadata.db +``` + +Place `app.db` and `gdrive.db` in `/var/lib/calibre-web/`. + +Restart Calibre: + +``` +sudo systemctl restart calibre-web.service +``` + diff --git a/docs/restore-nextcloud.md b/docs/restore-nextcloud.md index ad9381d..ff01b41 100644 --- a/docs/restore-nextcloud.md +++ b/docs/restore-nextcloud.md @@ -22,10 +22,10 @@ litestream restore -o nextcloud.db s3://noahmasur-backup.s3.us-west-002.backblaz Install Nextcloud. Then copy DB: ``` -sudo rm /var/lib/nextcloud/data/nextcloud.db* -sudo mv nextcloud.db /var/lib/nextcloud/data/ -sudo chown nextcloud:nextcloud /var/lib/nextcloud/data/nextcloud.db -sudo chmod 770 /var/lib/nextcloud/data/nextcloud.db +sudo rm /data/nextcloud/data/nextcloud.db* +sudo mv nextcloud.db /data/nextcloud/data/ +sudo chown nextcloud:nextcloud /data/nextcloud/data/nextcloud.db +sudo chmod 770 /data/nextcloud/data/nextcloud.db ``` Restart Nextcloud: @@ -37,7 +37,7 @@ sudo systemctl restart phpfpm-nextcloud.service Adjust Permissions and Directories: ``` -sudo mkdir /var/lib/nextcloud/data/noah/files -sudo chown nextcloud:nextcloud /var/lib/nextcloud/data/noah/files +sudo mkdir /data/nextcloud/data/noah/files +sudo chown nextcloud:nextcloud /data/nextcloud/data/noah/files ``` diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index c55b470..a9aa306 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -41,6 +41,7 @@ nixpkgs.lib.nixosSystem { caddy.enable = true; streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; + bookServer = "books.masu.rs"; samba.enable = true; backup.s3 = { diff --git a/modules/nixos/services/calibre.nix b/modules/nixos/services/calibre.nix index c596303..feb9846 100644 --- a/modules/nixos/services/calibre.nix +++ b/modules/nixos/services/calibre.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ config, pkgs, lib, ... }: + +let + + libraryPath = "/data/books"; + +in { options = { bookServer = lib.mkOption { @@ -6,6 +12,11 @@ description = "Hostname for Calibre library"; default = null; }; + backups.calibre = lib.mkOption { + type = lib.types.bool; + description = "Whether to backup Calibre library"; + default = true; + }; }; config = lib.mkIf (config.bookServer != null) { @@ -17,6 +28,7 @@ reverseProxyAuth.enable = false; enableBookConversion = true; enableBookUploading = true; + calibreLibrary = libraryPath; }; }; @@ -30,7 +42,7 @@ }]; # Run a backup on a schedule - systemd.timers.calibre-backup = { + systemd.timers.calibre-backup = lib.mkIf config.backups.calibre { timerConfig = { OnCalendar = "*-*-* 00:00:00"; # Once per day Unit = "calibre-backup.service"; @@ -39,24 +51,22 @@ }; # Backup Calibre data to object storage - systemd.services.calibre-backup = - let libraryPath = "/var/lib/calibre-web"; # Default location - in { - description = "Backup Calibre data"; - environment.AWS_ACCESS_KEY_ID = config.backup.s3.accessKeyId; - serviceConfig = { - Type = "oneshot"; - User = "calibre-web"; - Group = "backup"; - EnvironmentFile = config.secrets.backup.dest; - }; - script = '' - ${pkgs.awscli2}/bin/aws s3 sync \ - ${libraryPath}/ \ - s3://${config.backup.s3.bucket}/calibre/ \ - --endpoint-url=https://${config.backup.s3.endpoint} - ''; + systemd.services.calibre-backup = lib.mkIf config.backups.calibre { + description = "Backup Calibre data"; + environment.AWS_ACCESS_KEY_ID = config.backup.s3.accessKeyId; + serviceConfig = { + Type = "oneshot"; + User = "calibre-web"; + Group = "backup"; + EnvironmentFile = config.secrets.backup.dest; }; + script = '' + ${pkgs.awscli2}/bin/aws s3 sync \ + ${libraryPath}/ \ + s3://${config.backup.s3.bucket}/calibre/ \ + --endpoint-url=https://${config.backup.s3.endpoint} + ''; + }; }; From 5e4642b92e5c60f8e8c72ab8e0769ef3525cb78f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 09:05:45 -0500 Subject: [PATCH 241/391] fix: mail pass file set incorrectly --- modules/common/mail/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/common/mail/default.nix b/modules/common/mail/default.nix index 2afa517..f0f0ccd 100644 --- a/modules/common/mail/default.nix +++ b/modules/common/mail/default.nix @@ -67,7 +67,7 @@ notmuch.enable = false; passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ - builtins.toString ../../private/mailpass.age + builtins.toString ../../../private/mailpass.age }"; smtp = { host = "smtp.purelymail.com"; From d46e6dad6b702f4bde13034e660e480d664254de Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 19:59:58 +0000 Subject: [PATCH 242/391] open firewall for samba connection --- modules/nixos/services/samba.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix index 6c0fb7e..619feec 100644 --- a/modules/nixos/services/samba.nix +++ b/modules/nixos/services/samba.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: { +{ config, pkgs, lib, ... }: { options = { samba.enable = lib.mkEnableOption "Enable Samba sharing."; }; @@ -6,6 +6,7 @@ services.samba = lib.mkIf (config.samba.enable) { enable = true; + openFirewall = true; shares.video = { path = "/data/video"; browseable = "yes"; @@ -21,6 +22,12 @@ services.gvfs = lib.mkIf (config.gui.enable && config.nautilus.enable) { enable = true; }; + # Permissions required to mount Samba with GVFS, if not using desktop environment + environment.systemPackages = lib.mkIf (config.gui.enable + && config.nautilus.enable + && config.services.xserver.windowManager.i3.enable) + [ pkgs.lxqt.pxqt-policykit ]; + }; } From a7c04b59edc1765ebff4acf33cb7b92331d4f2e2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 20:44:55 +0000 Subject: [PATCH 243/391] use entire data dir for samba --- modules/nixos/services/samba.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix index 619feec..b259742 100644 --- a/modules/nixos/services/samba.nix +++ b/modules/nixos/services/samba.nix @@ -8,13 +8,13 @@ enable = true; openFirewall = true; shares.video = { - path = "/data/video"; + path = "/data"; browseable = "yes"; "read only" = "no"; "guest ok" = "no"; "force user" = config.user; "force group" = config.user; - comment = "Movies and TV"; + comment = "NAS"; }; }; From 18505d4cbbdae5b0805e57ccc8e19b0befb16cb0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:03:34 -0500 Subject: [PATCH 244/391] enable steam remote play --- modules/nixos/gaming/steam.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/nixos/gaming/steam.nix b/modules/nixos/gaming/steam.nix index 896c27e..7bfdbcb 100644 --- a/modules/nixos/gaming/steam.nix +++ b/modules/nixos/gaming/steam.nix @@ -5,15 +5,20 @@ config = lib.mkIf (config.gaming.steam.enable && pkgs.stdenv.isLinux) { hardware.steam-hardware.enable = true; unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ]; - environment.systemPackages = with pkgs; [ - steam + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + }; + + environment.systemPackages = with pkgs; [ # Enable terminal interaction steamPackages.steamcmd steam-tui ]; + }; } From 763f0bbdda3ac477f0bbfff733a3320409d0e241 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:04:06 -0500 Subject: [PATCH 245/391] enable trash on linux --- modules/common/shell/fish/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/common/shell/fish/default.nix b/modules/common/shell/fish/default.nix index c9f6d22..672d92b 100644 --- a/modules/common/shell/fish/default.nix +++ b/modules/common/shell/fish/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { users.users.${config.user}.shell = pkgs.fish; programs.fish.enable = @@ -11,7 +11,10 @@ programs.fish = { enable = true; - shellAliases = { ls = "exa"; }; + shellAliases = { + ls = "exa"; + trash = lib.mkIf pkgs.stdenv.isLinux "${pkgs.trash-cli}/bin/trash-put"; + }; functions = { commandline-git-commits = { description = "Insert commit into commandline"; @@ -90,6 +93,7 @@ sc = "systemctl"; scs = "systemctl status"; m = "make"; + t = "trash"; # Vim (overwritten by Neovim) v = "vim"; From ebacff725015fd2d7bf882fc1e6fbd6b1bd4e9d8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:04:28 -0500 Subject: [PATCH 246/391] remove unnecessary trash in darwin --- modules/darwin/homebrew.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 40731ab..8e44fa7 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -45,12 +45,6 @@ ]; }; - home-manager.users.${config.user} = { - - programs.fish.shellAbbrs.t = "trash"; - - }; - }; } From 59bd3590a4bc9be70091ac5c31cdf3669c8a670f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:07:03 -0500 Subject: [PATCH 247/391] turn on fstrim for ssds --- modules/nixos/hardware/default.nix | 1 + modules/nixos/hardware/disk.nix | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 modules/nixos/hardware/disk.nix diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 6d3f9f0..1353ec9 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -3,6 +3,7 @@ imports = [ ./audio.nix ./boot.nix + ./disk.nix ./keyboard.nix ./monitors.nix ./mouse.nix diff --git a/modules/nixos/hardware/disk.nix b/modules/nixos/hardware/disk.nix new file mode 100644 index 0000000..079823d --- /dev/null +++ b/modules/nixos/hardware/disk.nix @@ -0,0 +1,7 @@ +{ config, pkgs, lib, ... }: { + + # Enable fstrim, which tracks free space on SSDs for garbage collection + # More info: https://www.reddit.com/r/NixOS/comments/rbzhb1/if_you_have_a_ssd_dont_forget_to_enable_fstrim/ + services.fstrim.enable = true; + +} From 4502c5ff62c9c93f72831df12ddc08dd4b8635ed Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 6 Mar 2023 04:46:12 +0000 Subject: [PATCH 248/391] enhancements for samba server --- modules/nixos/hardware/networking.nix | 2 ++ modules/nixos/services/samba.nix | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/nixos/hardware/networking.nix b/modules/nixos/hardware/networking.nix index f157de9..03d91c3 100644 --- a/modules/nixos/hardware/networking.nix +++ b/modules/nixos/hardware/networking.nix @@ -9,6 +9,8 @@ networking.interfaces.enp5s0.useDHCP = true; networking.interfaces.wlp4s0.useDHCP = true; + networking.firewall.allowPing = lib.mkIf config.server true; + }; } diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix index b259742..6b0c7a4 100644 --- a/modules/nixos/services/samba.nix +++ b/modules/nixos/services/samba.nix @@ -7,7 +7,7 @@ services.samba = lib.mkIf (config.samba.enable) { enable = true; openFirewall = true; - shares.video = { + shares.data = { path = "/data"; browseable = "yes"; "read only" = "no"; @@ -18,6 +18,11 @@ }; }; + # Allows Windows clients to discover server + services.samba-wsdd.enable = true; + networking.firewall.allowedTCPPorts = [ 5357 ]; + networking.firewall.allowedUDPPorts = [ 3702 ]; + # Allow browsing Samba shares services.gvfs = lib.mkIf (config.gui.enable && config.nautilus.enable) { enable = true; }; From 31170a616f4a32f2db3dc5e19ee90bbf726cc303 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:47:52 -0500 Subject: [PATCH 249/391] client samba cleanup --- modules/nixos/services/samba.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix index 6b0c7a4..f4c3994 100644 --- a/modules/nixos/services/samba.nix +++ b/modules/nixos/services/samba.nix @@ -23,15 +23,15 @@ networking.firewall.allowedTCPPorts = [ 5357 ]; networking.firewall.allowedUDPPorts = [ 3702 ]; - # Allow browsing Samba shares + # Allow client browsing Samba and virtual filesystem shares services.gvfs = lib.mkIf (config.gui.enable && config.nautilus.enable) { enable = true; }; - # Permissions required to mount Samba with GVFS, if not using desktop environment - environment.systemPackages = lib.mkIf (config.gui.enable - && config.nautilus.enable - && config.services.xserver.windowManager.i3.enable) - [ pkgs.lxqt.pxqt-policykit ]; + # # Permissions required to mount Samba with GVFS, if not using desktop environment + # environment.systemPackages = lib.mkIf (config.gui.enable + # && config.nautilus.enable + # && config.services.xserver.windowManager.i3.enable) + # [ pkgs.lxqt.lxqt-policykit ]; }; From 12682a57e1faa3ddf3155397efcb6abe3dd10c61 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:30:25 -0500 Subject: [PATCH 250/391] macos: don't recreate canvas on app switcher --- .../Spoons/Launcher.spoon/init.lua | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua index 971b3c8..0e6e988 100644 --- a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua @@ -8,44 +8,44 @@ obj.name = "Launcher" obj.version = "0.1" obj.license = "MIT - https://opensource.org/licenses/MIT" -function DrawSwitcher() - -- Drawing - local width = hs.screen.mainScreen():fullFrame().w - local switcherWidth = 500 - local canv = hs.canvas.new({ - x = width / 2 - switcherWidth / 2, - y = 1, - h = 3, - w = switcherWidth, - }) - canv[#canv + 1] = { - action = "build", - type = "rectangle", - } - canv[#canv + 1] = { - type = "rectangle", - fillColor = { alpha = 1, red = 0.8, green = 0.6, blue = 0.3 }, - action = "fill", - } - return canv:show() -end +local width = hs.screen.mainScreen():fullFrame().w +local switcherWidth = 500 +obj.canvas = hs.canvas.new({ + x = width / 2 - switcherWidth / 2, + y = 1, + h = 3, + w = switcherWidth, +}) +-- Draw switcher +obj.canvas[#obj.canvas + 1] = { + action = "build", + type = "rectangle", +} +obj.canvas[#obj.canvas + 1] = { + type = "rectangle", + fillColor = { alpha = 1, red = 0.8, green = 0.6, blue = 0.3 }, + action = "fill", +} function obj:init() -- Begin launcher mode if self.launcher == nil then self.launcher = hs.hotkey.modal.new("ctrl", "space") + + print(self.canvas) + print(obj.canvas) end -- Behaviors on enter function self.launcher:entered() -- hs.alert("Entered mode") - self.canv = DrawSwitcher() + obj.canvas:show() end -- Behaviors on exit function self.launcher:exited() -- hs.alert("Exited mode") - self.canv:hide() + obj.canvas:hide() end -- Use escape to exit launcher mode @@ -54,7 +54,8 @@ function obj:init() end) -- Launcher shortcuts - self.launcher:bind("ctrl", "space", function() end) + self.launcher:bind("ctrl", "space", function() + end) self.launcher:bind("", "return", function() self:switch("@kitty@") end) From 183babd2f09d7cb4b33090701446f6efe21448ce Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:30:47 -0500 Subject: [PATCH 251/391] disable community cachix on macos ssl at work prevents connection --- modules/common/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/common/default.nix b/modules/common/default.nix index 1d04288..fedb3ed 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -88,8 +88,9 @@ settings = { # Add community Cachix to binary cache - substituters = [ "https://nix-community.cachix.org" ]; - trusted-public-keys = [ + substituters = lib.mkIf (!pkgs.stdenv.isDarwin) + [ "https://nix-community.cachix.org" ]; + trusted-public-keys = lib.mkIf (!pkgs.stdenv.isDarwin) [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; From 4d38d1094f9ec21634352a888d4238eb824b1c04 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:42:25 -0500 Subject: [PATCH 252/391] limit number of configurations not really a big problem, but worth adding just in case --- modules/nixos/hardware/boot.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/nixos/hardware/boot.nix b/modules/nixos/hardware/boot.nix index 47f8b9c..6b4dc2b 100644 --- a/modules/nixos/hardware/boot.nix +++ b/modules/nixos/hardware/boot.nix @@ -13,6 +13,9 @@ # Attempt to display GRUB on widescreen monitor gfxmodeEfi = "1920x1080"; + # Limit the total number of configurations to rollback + configurationLimit = 25; + # Install GRUB onto the boot disk # device = config.fileSystems."/boot".device; From bf4be1171800fb8a174b1bdc1d16e27a36bbb14f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:43:30 -0500 Subject: [PATCH 253/391] don't garbage collect direnv flakes --- modules/common/shell/direnv.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/common/shell/direnv.nix b/modules/common/shell/direnv.nix index 90d06ea..b5f5165 100644 --- a/modules/common/shell/direnv.nix +++ b/modules/common/shell/direnv.nix @@ -6,4 +6,10 @@ config = { whitelist = { prefix = [ config.dotfilesPath ]; }; }; }; + # Prevent garbage collection + nix.extraOptions = '' + keep-outputs = true + keep-derivations = true + ''; + } From 2acd9b3478224bd6e947107d4906165a871f581b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 18:14:30 -0500 Subject: [PATCH 254/391] add yt-dlp to media packages --- modules/common/applications/media.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index 84fe7eb..aa13f82 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -16,6 +16,7 @@ sxiv # Image viewer mupdf # PDF viewer zathura # PDF viewer + yt-dlp # Video downloader ]; # Set default for opening PDFs From 3cad3d2fb03ba1841a275ae56c09ad7e589a2324 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 18:14:52 -0500 Subject: [PATCH 255/391] bring back tabularize to neovim config --- modules/common/neovim/config/align.nix | 9 +++++++++ modules/common/neovim/package/default.nix | 1 + 2 files changed, 10 insertions(+) create mode 100644 modules/common/neovim/config/align.nix diff --git a/modules/common/neovim/config/align.nix b/modules/common/neovim/config/align.nix new file mode 100644 index 0000000..37abafe --- /dev/null +++ b/modules/common/neovim/config/align.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + plugins = [ pkgs.vimPlugins.tabular ]; + lua = '' + -- Align + vim.keymap.set("", "ta", ":Tabularize /") + vim.keymap.set("", "t#", ":Tabularize /#") + vim.keymap.set("", "tl", ":Tabularize /---") + ''; +} diff --git a/modules/common/neovim/package/default.nix b/modules/common/neovim/package/default.nix index f0991c1..a39767f 100644 --- a/modules/common/neovim/package/default.nix +++ b/modules/common/neovim/package/default.nix @@ -31,6 +31,7 @@ pkgs.neovimBuilder { package = pkgs.neovim-unwrapped; imports = [ + ../config/align.nix ../config/bufferline.nix ../config/completion.nix ../config/gitsigns.nix From d5b0405b9938e526089b87f7c46a3acf6fde56f2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:55:34 -0500 Subject: [PATCH 256/391] fix: default nvim desktop mime-apps --- modules/common/neovim/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/common/neovim/default.nix b/modules/common/neovim/default.nix index cf23eb3..69ec7b3 100644 --- a/modules/common/neovim/default.nix +++ b/modules/common/neovim/default.nix @@ -34,6 +34,14 @@ in { programs.kitty.settings.scrollback_pager = lib.mkForce '' ${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; + xdg.desktopEntries.nvim = { + name = "Neovim wrapper"; + exec = "kitty nvim %F"; + }; + xdg.mimeApps = { + defaultApplications."text/markdown" = [ "nvim.desktop" ]; + }; + }; # # Used for icons in Vim From 71d0d3ca148a9c65ea686976dab4967907a31472 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:56:07 -0500 Subject: [PATCH 257/391] move yt-dlp to separate file --- hosts/tempest/default.nix | 1 + modules/common/applications/default.nix | 1 + modules/common/applications/media.nix | 1 - modules/common/applications/yt-dlp.nix | 35 +++++++++++++++++++++++++ modules/nixos/system/user.nix | 5 ++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 modules/common/applications/yt-dlp.nix diff --git a/hosts/tempest/default.nix b/hosts/tempest/default.nix index 36ba623..ff80012 100644 --- a/hosts/tempest/default.nix +++ b/hosts/tempest/default.nix @@ -49,6 +49,7 @@ nixpkgs.lib.nixosSystem { # mullvad.enable = true; nixlang.enable = true; dotfiles.enable = true; + yt-dlp.enable = true; gaming = { enable = true; diff --git a/modules/common/applications/default.nix b/modules/common/applications/default.nix index 957b460..942f8d4 100644 --- a/modules/common/applications/default.nix +++ b/modules/common/applications/default.nix @@ -10,6 +10,7 @@ ./obsidian.nix ./qbittorrent.nix ./nautilus.nix + ./yt-dlp.nix ]; } diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index aa13f82..84fe7eb 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -16,7 +16,6 @@ sxiv # Image viewer mupdf # PDF viewer zathura # PDF viewer - yt-dlp # Video downloader ]; # Set default for opening PDFs diff --git a/modules/common/applications/yt-dlp.nix b/modules/common/applications/yt-dlp.nix new file mode 100644 index 0000000..33fab4c --- /dev/null +++ b/modules/common/applications/yt-dlp.nix @@ -0,0 +1,35 @@ +{ config, pkgs, lib, ... }: { + + options = { + yt-dlp = { + enable = lib.mkEnableOption { + description = "Enable YouTube downloader."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.yt-dlp.enable) { + home-manager.users.${config.user} = { + programs.yt-dlp = { + enable = true; + extraConfig = ""; + settings = { + no-continue = true; # Always re-download each fragment + no-overwrites = true; # Don't overwrite existing files + download-archive = "archive.log"; # Log of archives + embed-metadata = true; + embed-thumbnail = true; + embed-subs = true; + sub-langs = "en.*"; + concurrent-fragments = 4; # Parallel download chunks + }; + }; + + programs.fish.shellAbbrs.yt = "yt-dlp"; + + }; + + }; + +} diff --git a/modules/nixos/system/user.nix b/modules/nixos/system/user.nix index 5895624..3d2f09e 100644 --- a/modules/nixos/system/user.nix +++ b/modules/nixos/system/user.nix @@ -32,6 +32,11 @@ }; home-manager.users.${config.user}.xdg = { + + # Allow Nix to manage the default applications list + mimeApps.enable = true; + + # Set directories for application defaults userDirs = { enable = true; createDirectories = true; From 61d9b103b0647f5cd5dc5fb9da4655e08e63183d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:57:48 -0500 Subject: [PATCH 258/391] set local network hosts file --- modules/nixos/hardware/networking.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/nixos/hardware/networking.nix b/modules/nixos/hardware/networking.nix index 03d91c3..733af84 100644 --- a/modules/nixos/hardware/networking.nix +++ b/modules/nixos/hardware/networking.nix @@ -10,6 +10,10 @@ networking.interfaces.wlp4s0.useDHCP = true; networking.firewall.allowPing = lib.mkIf config.server true; + networking.hosts = { + "192.168.0.120" = [ "tempest" ]; + "192.168.0.218" = [ "swan" ]; + }; }; From 0df8af607d52acee059b020d3ae426b895d3b148 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:58:49 -0500 Subject: [PATCH 259/391] associate media applications as defaults --- modules/common/applications/media.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index 84fe7eb..1cfa0c6 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -19,9 +19,17 @@ ]; # Set default for opening PDFs - xdg.mimeApps.defaultApplications."application/pdf" = - [ "zathura.desktop" ]; - xdg.mimeApps.defaultApplications."image/*" = [ "sxiv.desktop" ]; + xdg.mimeApps = { + associations.added = { + "application/pdf" = [ "pwmt.zathura-cb.desktop" ]; + "image/*" = [ "sxiv.desktop" ]; + }; + associations.removed = { "application/pdf" = [ "mupdf.desktop" ]; }; + defaultApplications = { + "application/pdf" = [ "pwmt.zathura-cb.desktop" ]; + "image/*" = [ "sxiv.desktop" ]; + }; + }; }; From 3d73f8cab429659cbb4dd6b2c6507181e2c8e3df Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:45:00 -0500 Subject: [PATCH 260/391] switch to nixpkgs slack instead of homebrew --- flake.lock | 24 +++++++++---------- hosts/lookingglass/default.nix | 1 + modules/common/applications/default.nix | 3 ++- modules/common/applications/slack.nix | 19 +++++++++++++++ modules/darwin/hammerspoon.nix | 1 + .../Spoons/Launcher.spoon/init.lua | 2 +- modules/darwin/system.nix | 2 +- 7 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 modules/common/applications/slack.nix diff --git a/flake.lock b/flake.lock index 5e23f7f..16d78bd 100644 --- a/flake.lock +++ b/flake.lock @@ -94,11 +94,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1675471726, - "narHash": "sha256-526iHwidfdtZZ7aAU9od1/zbyfSFBEailBTet+Gvfqg=", + "lastModified": 1676854489, + "narHash": "sha256-hWmx3JFLNPGMtflyjgEn5GZydbLW3msjXvarS1NsBDM=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "813d55a3e3b3c0423eb5d1fcb4bf82197c9f7796", + "rev": "6a5cca0ea8dfab4718e1e43e243c80ba110c2364", "type": "github" }, "original": { @@ -176,11 +176,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1675935446, - "narHash": "sha256-WajulTn7QdwC7QuXRBavrANuIXE5z+08EdxdRw1qsNs=", + "lastModified": 1678271387, + "narHash": "sha256-H2dv/i1LRlunRtrESirELzfPWdlG/6ElDB1ksO529H4=", "owner": "nix-community", "repo": "home-manager", - "rev": "2dce7f1a55e785a22d61668516df62899278c9e4", + "rev": "36999b8d19eb6eebb41983ef017d7e0095316af2", "type": "github" }, "original": { @@ -301,11 +301,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1676973346, - "narHash": "sha256-rft8oGMocTAhUVqG3LW6I8K/Fo9ICGmNjRqaWTJwav0=", + "lastModified": 1676885936, + "narHash": "sha256-ZRKb6zBfTvdCOXI7nGC1L9UWSU5ay2ltxg+f5UIzBOU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d0d55259081f0b97c828f38559cad899d351cad1", + "rev": "b69883faca9542d135fa6bab7928ff1b233c167f", "type": "github" }, "original": { @@ -510,11 +510,11 @@ }, "utils": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", "type": "github" }, "original": { diff --git a/hosts/lookingglass/default.nix b/hosts/lookingglass/default.nix index 30c7e35..505f65d 100644 --- a/hosts/lookingglass/default.nix +++ b/hosts/lookingglass/default.nix @@ -44,6 +44,7 @@ darwin.lib.darwinSystem { lua.enable = true; kubernetes.enable = true; _1password.enable = true; + slack.enable = true; } ]; } diff --git a/modules/common/applications/default.nix b/modules/common/applications/default.nix index 942f8d4..77682e3 100644 --- a/modules/common/applications/default.nix +++ b/modules/common/applications/default.nix @@ -7,9 +7,10 @@ ./firefox.nix ./kitty.nix ./media.nix + ./nautilus.nix ./obsidian.nix ./qbittorrent.nix - ./nautilus.nix + ./slack.nix ./yt-dlp.nix ]; diff --git a/modules/common/applications/slack.nix b/modules/common/applications/slack.nix new file mode 100644 index 0000000..4bd866f --- /dev/null +++ b/modules/common/applications/slack.nix @@ -0,0 +1,19 @@ +{ config, pkgs, lib, ... }: { + + options = { + slack = { + enable = lib.mkEnableOption { + description = "Enable Slack."; + default = false; + }; + }; + }; + + config = lib.mkIf (config.gui.enable && config.slack.enable) { + unfreePackages = [ "slack" ]; + home-manager.users.${config.user} = { + home.packages = with pkgs; [ slack ]; + }; + }; + +} diff --git a/modules/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix index ebfc5e6..d4f5f87 100644 --- a/modules/darwin/hammerspoon.nix +++ b/modules/darwin/hammerspoon.nix @@ -16,6 +16,7 @@ firefox = "${pkgs.firefox-bin}/Applications/Firefox.app"; discord = "${pkgs.discord}/Applications/Discord.app"; kitty = "${pkgs.kitty}/Applications/kitty.app"; + slack = "${pkgs.slack}/Applications/Slack.app"; }; xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = ./hammerspoon/Spoons/MoveWindow.spoon; diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua index 0e6e988..57eb477 100644 --- a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua @@ -93,7 +93,7 @@ function obj:init() hs.reload() end) self.launcher:bind("", "S", function() - self:switch("Slack.app") + self:switch("@slack@") end) self.launcher:bind("", "Z", function() self:switch("zoom.us.app") diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 2212c04..6361485 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -166,7 +166,7 @@ echo "Choose and order dock icons" defaults write com.apple.dock persistent-apps -array \ "$(__dock_item /Applications/1Password.app)" \ - "$(__dock_item /Applications/Slack.app)" \ + "$(__dock_item ${pkgs.slack}/Applications/Slack.app)" \ "$(__dock_item /System/Applications/Calendar.app)" \ "$(__dock_item ${pkgs.firefox-bin}/Applications/Firefox.app)" \ "$(__dock_item /System/Applications/Messages.app)" \ From d4fa322fb1e994a2a819076d31a2f6d4475716a9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:45:11 -0500 Subject: [PATCH 261/391] fix: neovim xdg mimeapps don't work in macos --- modules/common/neovim/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/common/neovim/default.nix b/modules/common/neovim/default.nix index 69ec7b3..dd9ca3a 100644 --- a/modules/common/neovim/default.nix +++ b/modules/common/neovim/default.nix @@ -34,11 +34,11 @@ in { programs.kitty.settings.scrollback_pager = lib.mkForce '' ${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -''; - xdg.desktopEntries.nvim = { + xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux { name = "Neovim wrapper"; exec = "kitty nvim %F"; }; - xdg.mimeApps = { + xdg.mimeApps = lib.mkIf pkgs.stdenv.isLinux { defaultApplications."text/markdown" = [ "nvim.desktop" ]; }; From 42a5ad40de78364587edbf334a5d1e7c9a6eeb29 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 11 Mar 2023 14:14:25 -0500 Subject: [PATCH 262/391] add heroic game launcher --- modules/nixos/gaming/legendary.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/gaming/legendary.nix b/modules/nixos/gaming/legendary.nix index 018635e..ead410f 100644 --- a/modules/nixos/gaming/legendary.nix +++ b/modules/nixos/gaming/legendary.nix @@ -10,8 +10,8 @@ in { config = lib.mkIf config.gaming.legendary.enable { environment.systemPackages = with pkgs; [ legendary-gl - rare # GUI for Legendary (not working) wineWowPackages.stable # 32-bit and 64-bit wineWowPackages, see https://nixos.wiki/wiki/Wine + heroic # GUI launcher ]; home-manager.users.${config.user} = { From 2aea76c0e395023c9835cf8d5a1d7da64c5850d6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 11 Mar 2023 14:14:45 -0500 Subject: [PATCH 263/391] switch mpv to managed settings --- modules/common/applications/media.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index 1cfa0c6..d5a5eb6 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -12,12 +12,19 @@ config = lib.mkIf (config.gui.enable && config.media.enable) { home-manager.users.${config.user} = { home.packages = with pkgs; [ - mpv # Video viewer sxiv # Image viewer mupdf # PDF viewer zathura # PDF viewer ]; + # Video player + programs.mpv = { + enable = true; + bindings = { }; + config = { image-display-duration = 2; }; + scripts = [ pkgs.mpvScripts.autoload ]; + }; + # Set default for opening PDFs xdg.mimeApps = { associations.added = { From 86076f08444054b228996fcc417d7789bd66b712 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 13:24:16 +0000 Subject: [PATCH 264/391] add arr services --- hosts/swan/default.nix | 1 + modules/nixos/services/arr.nix | 71 +++++++++++++++++++++++++ modules/nixos/services/default.nix | 1 + modules/nixos/services/transmission.nix | 4 +- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 modules/nixos/services/arr.nix diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index a9aa306..07e9452 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -42,6 +42,7 @@ nixpkgs.lib.nixosSystem { streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; bookServer = "books.masu.rs"; + arrServer = "download.masu.rs"; samba.enable = true; backup.s3 = { diff --git a/modules/nixos/services/arr.nix b/modules/nixos/services/arr.nix new file mode 100644 index 0000000..393ec27 --- /dev/null +++ b/modules/nixos/services/arr.nix @@ -0,0 +1,71 @@ +{ config, lib, ... }: + +{ + + options = { + arrServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for arr services"; + default = null; + }; + }; + + config = lib.mkIf (config.arrServer != null) { + + services.sonarr.enable = true; + services.radarr.enable = true; + services.bazarr.enable = true; + services.prowlarr.enable = true; + + # Requires updating the base_url config value in each service + # If you try to rewrite the URL, the service won't redirect properly + caddy.routes = [ + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/sonarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8989"; }]; + }]; + } + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/radarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:7878"; }]; + }]; + } + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/prowlarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:9696"; }]; + }]; + } + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/bazarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:6767"; }]; + }]; + } + ]; + + }; + +} diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index 46f9ed7..9fb0c07 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ + ./arr.nix ./backups.nix ./caddy.nix ./calibre.nix diff --git a/modules/nixos/services/transmission.nix b/modules/nixos/services/transmission.nix index fc805c1..ff470b2 100644 --- a/modules/nixos/services/transmission.nix +++ b/modules/nixos/services/transmission.nix @@ -41,7 +41,9 @@ }; # Create reverse proxy for web UI - caddy.routes = [{ + caddy.routes = lib.mkAfter [{ + group = + lib.mkIf (config.arrServer == config.transmissionServer) "download"; match = [{ host = [ config.transmissionServer ]; }]; handle = [{ handler = "reverse_proxy"; From e6dbed2e17182769249add38366b324655246193 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 13:24:25 +0000 Subject: [PATCH 265/391] enable caddy logfile --- modules/nixos/services/caddy.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/nixos/services/caddy.nix b/modules/nixos/services/caddy.nix index bac9b26..ab24506 100644 --- a/modules/nixos/services/caddy.nix +++ b/modules/nixos/services/caddy.nix @@ -24,6 +24,16 @@ listen = [ ":443" ]; routes = config.caddy.routes; errors.routes = config.caddy.blocks; + # logs = { }; # Uncomment to collect access logs + }; + logging.logs.main = { + encoder = { format = "console"; }; + writer = { + output = "file"; + filename = "${config.services.caddy.logDir}/caddy.log"; + roll = true; + }; + level = "INFO"; }; }); From 58593778025a90d6871087ae317c6695e8e350aa Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 17:07:54 -0400 Subject: [PATCH 266/391] fix: arr options when not used --- modules/nixos/services/arr.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/nixos/services/arr.nix b/modules/nixos/services/arr.nix index 393ec27..2d27378 100644 --- a/modules/nixos/services/arr.nix +++ b/modules/nixos/services/arr.nix @@ -1,10 +1,8 @@ -{ config, lib, ... }: - -{ +{ config, lib, ... }: { options = { arrServer = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Hostname for arr services"; default = null; }; From 5002c881f7bde33a235db62a5df30b89513f385d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 17:07:41 -0400 Subject: [PATCH 267/391] fix: mail not syncing read and deleted --- flake.nix | 2 ++ hosts/swan/default.nix | 1 - modules/common/mail/aerc.nix | 5 +++++ modules/common/mail/default.nix | 20 ++++++++++++++------ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 93035b8..0280f2d 100644 --- a/flake.nix +++ b/flake.nix @@ -111,6 +111,8 @@ gitName = fullName; gitEmail = "7386960+nmasur@users.noreply.github.com"; mail.server = "noahmasur.com"; + mail.imapHost = "imap.purelymail.com"; + mail.smtpHost = "smtp.purelymail.com"; dotfilesRepo = "git@github.com:nmasur/dotfiles"; }; diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 07e9452..30a1f7c 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -12,7 +12,6 @@ nixpkgs.lib.nixosSystem { ./hardware-configuration.nix ../../modules/common ../../modules/nixos - (removeAttrs globals [ "mail.server" ]) wsl.nixosModules.wsl home-manager.nixosModules.home-manager disko.nixosModules.disko diff --git a/modules/common/mail/aerc.nix b/modules/common/mail/aerc.nix index c85d62b..7960dff 100644 --- a/modules/common/mail/aerc.nix +++ b/modules/common/mail/aerc.nix @@ -181,6 +181,11 @@ }; }; + xdg.desktopEntries.aerc = lib.mkIf pkgs.stdenv.isLinux { + name = "aerc"; + exec = "kitty aerc %u"; + }; + programs.fish.shellAbbrs = { ae = "aerc"; }; }; diff --git a/modules/common/mail/default.nix b/modules/common/mail/default.nix index f0f0ccd..56c667b 100644 --- a/modules/common/mail/default.nix +++ b/modules/common/mail/default.nix @@ -10,9 +10,17 @@ default = config.user; }; mail.server = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "Server name for the email address."; }; + mail.imapHost = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Server host for IMAP (reading mail)."; + }; + mail.smtpHost = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Server host for SMTP (sending mail)."; + }; }; config = lib.mkIf config.mail.enable { @@ -42,7 +50,7 @@ folders = { }; getmail = { }; imap = { - host = "imap.purelymail.com"; + host = config.mail.imapHost; port = 993; tls.enable = true; }; @@ -55,9 +63,9 @@ maildir = { path = "main"; }; mbsync = { enable = true; - create = "maildir"; - expunge = "none"; - remove = "none"; + create = "both"; + expunge = "both"; + remove = "both"; patterns = [ "*" ]; extraConfig.channel = { CopyArrivalDate = "yes"; # Sync time of original message @@ -70,7 +78,7 @@ builtins.toString ../../../private/mailpass.age }"; smtp = { - host = "smtp.purelymail.com"; + host = config.mail.smtpHost; port = 465; tls.enable = true; }; From f219ce45c8696c863a095bce0f10a4938a67b776 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 19:00:59 -0400 Subject: [PATCH 268/391] enable actual bash support --- modules/common/shell/bash/default.nix | 20 ++++++++++++++++++++ modules/common/shell/default.nix | 1 + modules/common/shell/fish/default.nix | 1 - 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 modules/common/shell/bash/default.nix diff --git a/modules/common/shell/bash/default.nix b/modules/common/shell/bash/default.nix new file mode 100644 index 0000000..06a8367 --- /dev/null +++ b/modules/common/shell/bash/default.nix @@ -0,0 +1,20 @@ +{ config, pkgs, lib, ... }: { + + config = { + home-manager.users.${config.user} = { + + programs.bash = { + enable = true; + shellAliases = + config.home-manager.users.${config.user}.programs.fish.shellAliases; + initExtra = ""; + profileExtra = ""; + }; + + programs.starship.enableBashIntegration = false; + programs.zoxide.enableBashIntegration = true; + programs.fzf.enableBashIntegration = true; + + }; + }; +} diff --git a/modules/common/shell/default.nix b/modules/common/shell/default.nix index 9359d15..82af041 100644 --- a/modules/common/shell/default.nix +++ b/modules/common/shell/default.nix @@ -1,5 +1,6 @@ { ... }: { imports = [ + ./bash ./charm.nix ./direnv.nix ./fish diff --git a/modules/common/shell/fish/default.nix b/modules/common/shell/fish/default.nix index 672d92b..d2da044 100644 --- a/modules/common/shell/fish/default.nix +++ b/modules/common/shell/fish/default.nix @@ -76,7 +76,6 @@ set -g fish_cursor_replace_one underscore ''; loginShellInit = ""; - shellAliases = { }; shellAbbrs = { # Directory aliases From 78b364afd7fee0b3c8ee4a58316c27a593daa6fb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 20:09:41 -0400 Subject: [PATCH 269/391] launch aerc with super+E --- modules/common/mail/aerc.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/common/mail/aerc.nix b/modules/common/mail/aerc.nix index 7960dff..6f3969c 100644 --- a/modules/common/mail/aerc.nix +++ b/modules/common/mail/aerc.nix @@ -185,6 +185,12 @@ name = "aerc"; exec = "kitty aerc %u"; }; + xsession.windowManager.i3.config.keybindings = + lib.mkIf pkgs.stdenv.isLinux { + "${ + config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier + }+Shift+e" = "exec --no-startup-id kitty aerc"; + }; programs.fish.shellAbbrs = { ae = "aerc"; }; From 64590c539b514caa960cbd2660fd279fc91d6093 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 20:09:56 -0400 Subject: [PATCH 270/391] reorder utilities alphabetically also add bc --- modules/common/shell/utilities.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/common/shell/utilities.nix b/modules/common/shell/utilities.nix index 6f2d1a4..06eba0f 100644 --- a/modules/common/shell/utilities.nix +++ b/modules/common/shell/utilities.nix @@ -18,21 +18,22 @@ in { home-manager.users.${config.user} = { home.packages = with pkgs; [ - unzip # Extract zips + age # Encryption + bc # Calculator + dig # DNS lookup + fd # find + htop # Show system processes + inetutils # Includes telnet, whois + jq # JSON manipulation + lf # File viewer + qrencode # Generate qr codes rsync # Copy folders ripgrep # grep - fd # find sd # sed - jq # JSON manipulation tealdeer # Cheatsheets tree # View directory hierarchy - htop # Show system processes - qrencode # Generate qr codes vimv-rs # Batch rename files - dig # DNS lookup - lf # File viewer - inetutils # Includes telnet, whois - age # Encryption + unzip # Extract zips ]; programs.zoxide.enable = true; # Shortcut jump command From 28576c1b8f302cefedb23f2cdd878758c87abaf8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 16 Mar 2023 14:52:20 -0400 Subject: [PATCH 271/391] update lockfile --- flake.lock | 132 ++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/flake.lock b/flake.lock index 16d78bd..50effed 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "Comment-nvim-src": { "flake": false, "locked": { - "lastModified": 1674040818, - "narHash": "sha256-7UtZAE9tPlnpeHS2LLol/LGVOxptDXNKWXHNHvFBNk4=", + "lastModified": 1678452935, + "narHash": "sha256-mVJJJ9fUJYgVyGZnW8e6P5QWB0K8nuhTwSWzlBvxv2M=", "owner": "numToStr", "repo": "Comment.nvim", - "rev": "eab2c83a0207369900e92783f56990808082eac2", + "rev": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20", "type": "github" }, "original": { @@ -19,11 +19,11 @@ "bufferline-nvim-src": { "flake": false, "locked": { - "lastModified": 1676130961, - "narHash": "sha256-3LT45i0eSMfUV9EBrtdtzHxFKRATIhRy/faDd3lI3mA=", + "lastModified": 1677796018, + "narHash": "sha256-tuGitJQ2eXB9/SIHAyPrEVgy2n++GOlBOPLvFv3Ds4E=", "owner": "akinsho", "repo": "bufferline.nvim", - "rev": "84b0822b2af478d0b4f7b0f9249ca218855331db", + "rev": "3677aceb9a72630b0613e56516c8f7151b86f95c", "type": "github" }, "original": { @@ -76,11 +76,11 @@ ] }, "locked": { - "lastModified": 1677116397, - "narHash": "sha256-2OHwhv4k1SDEuNxhq+zluvrd5pbW8d4TP9NKW4B8iO8=", + "lastModified": 1678912468, + "narHash": "sha256-oUo6ZrsuqymuMLLvGfgnQ464OMKnUONv+ryea07iGrE=", "owner": "nix-community", "repo": "disko", - "rev": "8fddb2fd721365fa77ff68b709539639d4dc65d7", + "rev": "e8650fc36bf9d2acb411ba0047f863b8e481e3bb", "type": "github" }, "original": { @@ -94,11 +94,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1676854489, - "narHash": "sha256-hWmx3JFLNPGMtflyjgEn5GZydbLW3msjXvarS1NsBDM=", + "lastModified": 1678841558, + "narHash": "sha256-rYysvBEPl6swrKivgRq2JWCmfgOAiuMS0TLFOEm9PS8=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "6a5cca0ea8dfab4718e1e43e243c80ba110c2364", + "rev": "4bf99d168a281e6db4da91af2d25922f3790a873", "type": "github" }, "original": { @@ -125,11 +125,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", "type": "github" }, "original": { @@ -155,11 +155,11 @@ }, "flake-utils_3": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", "type": "github" }, "original": { @@ -176,11 +176,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1678271387, - "narHash": "sha256-H2dv/i1LRlunRtrESirELzfPWdlG/6ElDB1ksO529H4=", + "lastModified": 1678916824, + "narHash": "sha256-YPQAQ0x0wLvbQ/vaEj8o+0hRfbBNR0teTJ6QsG0yzw4=", "owner": "nix-community", "repo": "home-manager", - "rev": "36999b8d19eb6eebb41983ef017d7e0095316af2", + "rev": "c8cb60b8a15c90b2bbc416c182532620602edb48", "type": "github" }, "original": { @@ -197,11 +197,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1676110678, - "narHash": "sha256-hemg8rMKS2me2Wua9ZG/0aQ8fEOfytjyKB+WYcXfEKE=", + "lastModified": 1678728829, + "narHash": "sha256-KbA8uakGfjfvRH+Td/VegiLdHrnqIZHkMTQ5XBjL2dE=", "owner": "oxalica", "repo": "nil", - "rev": "ce2e0b5d60fe497134050796f7d12ffb6b50eb28", + "rev": "e7045f1779fd202a3316f84b864c304f339cccea", "type": "github" }, "original": { @@ -233,11 +233,11 @@ }, "nixlib": { "locked": { - "lastModified": 1636849918, - "narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=", + "lastModified": 1677373009, + "narHash": "sha256-kxhz4QUP8tXa/yVSpEzDDZSEp9FvhzRqZzb+SeUaekw=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5", + "rev": "c9d4f2476046c6a7a2ce3c2118c48455bf0272ea", "type": "github" }, "original": { @@ -254,11 +254,11 @@ ] }, "locked": { - "lastModified": 1674666581, - "narHash": "sha256-KNI2s/xrL7WOYaPJAWKBtb7cCH3335rLfsL+B+ssuGY=", + "lastModified": 1678351966, + "narHash": "sha256-tRFEU0lu3imZb3dtELBY+UbEhWXbb0xlBrsIlpICb+A=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "6a5dc1d3d557ea7b5c19b15ff91955124d0400fa", + "rev": "0c043999b16caba6fb571af2d228775729829943", "type": "github" }, "original": { @@ -285,11 +285,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1675309347, - "narHash": "sha256-D3CQ6HRDT2m3XJlrzb5jKq4vNFR5xFTEFKC7iSjlFpM=", + "lastModified": 1678298120, + "narHash": "sha256-iaV5xqgn29xy765Js3EoZePQyZIlLZA3pTYtTnKkejg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "006c3bd4dd2f5d1d2094047f307cbf9e2b73d9c5", + "rev": "1e383aada51b416c6c27d4884d2e258df201bc11", "type": "github" }, "original": { @@ -301,11 +301,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1676885936, - "narHash": "sha256-ZRKb6zBfTvdCOXI7nGC1L9UWSU5ay2ltxg+f5UIzBOU=", + "lastModified": 1678819893, + "narHash": "sha256-lfA6WGdxPsPkBK5Y19ltr5Sn7v7MlT+jpZ4nUgco0Xs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b69883faca9542d135fa6bab7928ff1b233c167f", + "rev": "7067edc68c035e21780259ed2d26e1f164addaa2", "type": "github" }, "original": { @@ -317,11 +317,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1674868155, - "narHash": "sha256-eFNm2h6fNbgD7ZpO4MHikCB5pSnCJ7DTmwPisjetmwc=", + "lastModified": 1677779205, + "narHash": "sha256-6DBjL9wjq86p2GczmwnHtFRnWPBPItc67gapWENBgX8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ce20e9ebe1903ea2ba1ab006ec63093020c761cb", + "rev": "96e18717904dfedcd884541e5a92bf9ff632cf39", "type": "github" }, "original": { @@ -334,11 +334,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1676246878, - "narHash": "sha256-hAUEa2zNsYXQ+TsHYHBzcW67lCxhiD7x+uPbdOZwY8o=", + "lastModified": 1678896738, + "narHash": "sha256-Ah8Wy1C3Cd75vw/8IRrYNZgSYXTgTxZwpABMb2LzW8Q=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "d4594231a06cecce73a78a256b0d7c7ab51f7dd5", + "rev": "2fcc10637b325e656d45a760901e1e05170e36c9", "type": "github" }, "original": { @@ -349,11 +349,11 @@ }, "nur": { "locked": { - "lastModified": 1676251563, - "narHash": "sha256-itLKR2Haeh5wQ6dxkuZ8L5gwp3+CAggpN+w2e7cLQPg=", + "lastModified": 1678915555, + "narHash": "sha256-U4BDXptYZH2j59syOxuAbkpioKxqW+bC3LbJK+Tofw8=", "owner": "nix-community", "repo": "nur", - "rev": "9a8b28a9d6611f6af9f7abb3e690fc755d6906fe", + "rev": "40cbb3e28ea69c29375f6e0d01988caf50244f1f", "type": "github" }, "original": { @@ -365,11 +365,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1676175675, - "narHash": "sha256-Wg3NatT4DRBMF6hCxK4C2DC+geFMpfFUFogPbqeMt6E=", + "lastModified": 1678883048, + "narHash": "sha256-D/KLRg2yenxBX+24njWg2c494hI3uKIcZGhQbk+jg1c=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "1712672e4da3003a0dd9f771d30389600b360f42", + "rev": "63f4c0082f007d2356df4bc335f55e6d414da89c", "type": "github" }, "original": { @@ -381,11 +381,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1676244722, - "narHash": "sha256-xoSekdZhWr59qTOM0/ihYiuKiwHiKYb42Ep5JHn65UM=", + "lastModified": 1678748807, + "narHash": "sha256-u9ZLBL4FY/bkvl4+ofKifyEHM9+KhqeYovhr9VQYG7c=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "ba1778e061f25814bc5940be886a7f41d7d7736e", + "rev": "1d79a64a88af47ddbb55f4805ab537d11d5b908e", "type": "github" }, "original": { @@ -397,11 +397,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1676240774, - "narHash": "sha256-eRSU/9ysSvTyYxBrp9Whg0eXgAOsCdmIHMlYZK7bjRg=", + "lastModified": 1678916699, + "narHash": "sha256-I1uXrvDGHDwv9k1shITQvIGGNCiB7TBeDHRC1cWWd7s=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "7eb5f1a2e3949496f26c4084b521b30f2d08137a", + "rev": "fa0644667ea7ee7a72efdb69c471de4953a11019", "type": "github" }, "original": { @@ -447,11 +447,11 @@ ] }, "locked": { - "lastModified": 1675391458, - "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "lastModified": 1678415622, + "narHash": "sha256-tems1jHETCYEen8QrW61yVVX0F4zOGy4ImB43iDc7bY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "rev": "9f687941160108f89dd8bd2c650d32c15a35c7c7", "type": "github" }, "original": { @@ -463,11 +463,11 @@ "telescope-nvim-src": { "flake": false, "locked": { - "lastModified": 1675149856, - "narHash": "sha256-L4Kw94CUy6N7zcyy9INuR/O0fxQ7sp0IvGd/u7fHxMA=", + "lastModified": 1677414372, + "narHash": "sha256-QmyVJ/LZFtb/qqD5Q5fHsqAGgqaOT9XkVoLyOcqM14w=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "203bf5609137600d73e8ed82703d6b0e320a5f36", + "rev": "a3f17d3baf70df58b9d3544ea30abe52a7a832c2", "type": "github" }, "original": { @@ -495,11 +495,11 @@ "toggleterm-nvim-src": { "flake": false, "locked": { - "lastModified": 1675358836, - "narHash": "sha256-9O7p/7tRStg51OFhMc88M5ewYquiYC9x9CV4s5veVP8=", + "lastModified": 1678645191, + "narHash": "sha256-nK9eUHeFjZtUPC4cOCILg7J54rDHGI52AIXX5j7E4rE=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "19aad0f41f47affbba1274f05e3c067e6d718e1e", + "rev": "c8e982ad2739eeb0b13d0fecb14820c9bf5e3da0", "type": "github" }, "original": { @@ -546,11 +546,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1676126384, - "narHash": "sha256-3aAnN891Cb1pizewAgaHIo3W1WbAjXtoWuX8n3j8YoI=", + "lastModified": 1678648312, + "narHash": "sha256-aY3CBNyenTUkStQhwigm30+BjXQyA8rCChGD+Z98qqE=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "a1c7e8bebac32cfac7aa8498bdfc60cbff13eb50", + "rev": "c6f663e8583912059605b55c07583b6e96b5e690", "type": "github" }, "original": { From 2176a53c4ac28c120f260886ce2206d19ec7e051 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:29:20 -0400 Subject: [PATCH 272/391] setup amd gpu fancontrol curve --- hosts/tempest/hardware-configuration.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hosts/tempest/hardware-configuration.nix b/hosts/tempest/hardware-configuration.nix index 113ff46..660d9ba 100644 --- a/hosts/tempest/hardware-configuration.nix +++ b/hosts/tempest/hardware-configuration.nix @@ -37,4 +37,19 @@ powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + hardware.fancontrol.enable = true; + hardware.fancontrol.config = '' + # Configuration file generated by pwmconfig, changes will be lost + INTERVAL=10 + DEVPATH=hwmon0=devices/pci0000:00/0000:00:03.1/0000:06:00.0/0000:07:00.0/0000:08:00.0 + DEVNAME=hwmon0=amdgpu + FCTEMPS=hwmon0/pwm1=hwmon0/temp1_input + FCFANS= hwmon0/pwm1=hwmon0/fan1_input + MINTEMP=hwmon0/pwm1=30 + MAXTEMP=hwmon0/pwm1=70 + MINSTART=hwmon0/pwm1=150 + MINSTOP=hwmon0/pwm1=12 + MINPWM=hwmon0/pwm1=12 + ''; } From da8973200183c568f86b58a8efbb226539fc89ec Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 19 Mar 2023 10:45:52 -0400 Subject: [PATCH 273/391] switch to nsxiv and set media for aerc --- modules/common/applications/media.nix | 6 +++--- modules/common/mail/aerc.nix | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index d5a5eb6..a5e4452 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -12,7 +12,7 @@ config = lib.mkIf (config.gui.enable && config.media.enable) { home-manager.users.${config.user} = { home.packages = with pkgs; [ - sxiv # Image viewer + nsxiv # Image viewer mupdf # PDF viewer zathura # PDF viewer ]; @@ -29,12 +29,12 @@ xdg.mimeApps = { associations.added = { "application/pdf" = [ "pwmt.zathura-cb.desktop" ]; - "image/*" = [ "sxiv.desktop" ]; + "image/*" = [ "nsxiv.desktop" ]; }; associations.removed = { "application/pdf" = [ "mupdf.desktop" ]; }; defaultApplications = { "application/pdf" = [ "pwmt.zathura-cb.desktop" ]; - "image/*" = [ "sxiv.desktop" ]; + "image/*" = [ "nsxiv.desktop" ]; }; }; diff --git a/modules/common/mail/aerc.nix b/modules/common/mail/aerc.nix index 6f3969c..bfd0241 100644 --- a/modules/common/mail/aerc.nix +++ b/modules/common/mail/aerc.nix @@ -170,6 +170,8 @@ "${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize"; "application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh"; "application/pdf" = "${pkgs.zathura}/bin/zathura -"; + "audio/*" = "${pkgs.mpv}/bin/mpv -"; + "image/*" = "${pkgs.feh}/bin/feh -"; }; }; }; From c53f1470ee04890f461796ba0d14cce393f2b5c3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 19 Mar 2023 12:49:41 -0400 Subject: [PATCH 274/391] allow rofi-systemd to use kitty terminal --- modules/common/applications/kitty.nix | 16 ++++++++++++++-- modules/nixos/graphical/rofi.nix | 8 ++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/common/applications/kitty.nix b/modules/common/applications/kitty.nix index 8de7236..95e67df 100644 --- a/modules/common/applications/kitty.nix +++ b/modules/common/applications/kitty.nix @@ -10,9 +10,21 @@ }; config = lib.mkIf (config.gui.enable && config.kitty.enable) { + + # Set the Rofi-Systemd terminal for viewing logs + environment.sessionVariables.ROFI_SYSTEMD_TERM = + lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty"; + home-manager.users.${config.user} = { - # xsession.windowManager.i3.config.terminal = "kitty"; - # programs.rofi.terminal = "${pkgs.kitty}/bin/kitty"; + + # Set the i3 terminal + xsession.windowManager.i3.config.terminal = + lib.mkIf pkgs.stdenv.isLinux "kitty"; + + # Set the Rofi terminal for running programs + programs.rofi.terminal = + lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty"; + programs.kitty = { enable = true; environment = { }; diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index 7a580c6..a8e09aa 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -144,9 +144,13 @@ }; - launcherCommand = "${pkgs.rofi}/bin/rofi -show run -modi run"; + launcherCommand = "${ + config.home-manager.users.${config.user}.programs.rofi.finalPackage + }/bin/rofi -show run -modi run"; systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; - altTabCommand = "${pkgs.rofi}/bin/rofi -show window -modi window"; + altTabCommand = "${ + config.home-manager.users.${config.user}.programs.rofi.finalPackage + }/bin/rofi -show window -modi window"; }; From 4406116203cf333fe16ddc867837a3d0f8ebd12a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 19 Mar 2023 23:35:06 -0400 Subject: [PATCH 275/391] adjust fan curve --- hosts/tempest/hardware-configuration.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hosts/tempest/hardware-configuration.nix b/hosts/tempest/hardware-configuration.nix index 660d9ba..648ecb0 100644 --- a/hosts/tempest/hardware-configuration.nix +++ b/hosts/tempest/hardware-configuration.nix @@ -46,10 +46,11 @@ DEVNAME=hwmon0=amdgpu FCTEMPS=hwmon0/pwm1=hwmon0/temp1_input FCFANS= hwmon0/pwm1=hwmon0/fan1_input - MINTEMP=hwmon0/pwm1=30 + MINTEMP=hwmon0/pwm1=50 MAXTEMP=hwmon0/pwm1=70 - MINSTART=hwmon0/pwm1=150 - MINSTOP=hwmon0/pwm1=12 - MINPWM=hwmon0/pwm1=12 + MINSTART=hwmon0/pwm1=100 + MINSTOP=hwmon0/pwm1=10 + MINPWM=hwmon0/pwm1=10 + MAXPWM=hwmon0/pwm1=240 ''; } From 1b798f5af0a55e33737ef4724d02303ac27ec76a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Mar 2023 03:35:54 +0000 Subject: [PATCH 276/391] grant permissions to service directories --- modules/nixos/services/arr.nix | 5 +++++ modules/nixos/services/calibre.nix | 3 +++ 2 files changed, 8 insertions(+) diff --git a/modules/nixos/services/arr.nix b/modules/nixos/services/arr.nix index 2d27378..825448c 100644 --- a/modules/nixos/services/arr.nix +++ b/modules/nixos/services/arr.nix @@ -15,6 +15,11 @@ services.bazarr.enable = true; services.prowlarr.enable = true; + # Grant users access to destination directories + users.users.sonarr.extraGroups = [ "jellyfin" ]; + users.users.radarr.extraGroups = [ "jellyfin" ]; + users.users.bazarr.extraGroups = [ "jellyfin" ]; + # Requires updating the base_url config value in each service # If you try to rewrite the URL, the service won't redirect properly caddy.routes = [ diff --git a/modules/nixos/services/calibre.nix b/modules/nixos/services/calibre.nix index feb9846..75f44c4 100644 --- a/modules/nixos/services/calibre.nix +++ b/modules/nixos/services/calibre.nix @@ -41,6 +41,9 @@ in { }]; }]; + # Grant user access to Calibre directories + users.users.${config.user}.extraGroups = [ "calibre-web" ]; + # Run a backup on a schedule systemd.timers.calibre-backup = lib.mkIf config.backups.calibre { timerConfig = { From e7468ecc469e5a21624f11efedefc8fc5252da2c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 20 Mar 2023 03:36:15 +0000 Subject: [PATCH 277/391] fix: swan globals not included --- hosts/swan/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index 30a1f7c..bef02b9 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -12,6 +12,7 @@ nixpkgs.lib.nixosSystem { ./hardware-configuration.nix ../../modules/common ../../modules/nixos + globals wsl.nixosModules.wsl home-manager.nixosModules.home-manager disko.nixosModules.disko From bda59eeb4ae1c4911a35dcf080c4d22f08135357 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 21 Mar 2023 18:37:22 -0400 Subject: [PATCH 278/391] enable num lock on login --- modules/nixos/hardware/keyboard.nix | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/nixos/hardware/keyboard.nix b/modules/nixos/hardware/keyboard.nix index e5eee1b..4c23bee 100644 --- a/modules/nixos/hardware/keyboard.nix +++ b/modules/nixos/hardware/keyboard.nix @@ -1,15 +1,22 @@ -{ ... }: { +{ config, ... }: { - services.xserver = { + config = { - layout = "us"; + services.xserver = { - # Keyboard responsiveness - autoRepeatDelay = 250; - autoRepeatInterval = 40; + layout = "us"; - # Swap escape key with caps lock key - xkbOptions = "eurosign:e,caps:swapescape"; + # Keyboard responsiveness + autoRepeatDelay = 250; + autoRepeatInterval = 40; + + # Swap escape key with caps lock key + xkbOptions = "eurosign:e,caps:swapescape"; + + }; + + # Enable num lock on login + home-manager.users.${config.user}.xsession.numlock.enable = true; }; From 9b97c9ac845890718da70b29e7086e314cb437cc Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 22 Mar 2023 16:20:30 -0400 Subject: [PATCH 279/391] update lockfile, fix darwin --- flake.lock | 42 +++++++++---------- flake.nix | 2 + modules/common/applications/kitty.nix | 7 +++- modules/common/default.nix | 9 +--- .../Spoons/Launcher.spoon/init.lua | 1 + modules/nixos/graphical/rofi.nix | 4 ++ 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/flake.lock b/flake.lock index 50effed..4d929fa 100644 --- a/flake.lock +++ b/flake.lock @@ -94,11 +94,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1678841558, - "narHash": "sha256-rYysvBEPl6swrKivgRq2JWCmfgOAiuMS0TLFOEm9PS8=", + "lastModified": 1679446046, + "narHash": "sha256-CBjVE3Sj7Ls1pffxGavqPXRkaLYy1+O88NzBwNdgNcY=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "4bf99d168a281e6db4da91af2d25922f3790a873", + "rev": "1531f1477881e76c67b123a55f3d44ed7f83a4ba", "type": "github" }, "original": { @@ -176,11 +176,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1678916824, - "narHash": "sha256-YPQAQ0x0wLvbQ/vaEj8o+0hRfbBNR0teTJ6QsG0yzw4=", + "lastModified": 1679067095, + "narHash": "sha256-G2dJQURL/CCi+8RP6jNJG8VqgtzEMCA+6mNodd3VR6E=", "owner": "nix-community", "repo": "home-manager", - "rev": "c8cb60b8a15c90b2bbc416c182532620602edb48", + "rev": "3239e0b40f242f47bf6c0c37b2fd35ab3e76e370", "type": "github" }, "original": { @@ -301,11 +301,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1678819893, - "narHash": "sha256-lfA6WGdxPsPkBK5Y19ltr5Sn7v7MlT+jpZ4nUgco0Xs=", + "lastModified": 1679262748, + "narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7067edc68c035e21780259ed2d26e1f164addaa2", + "rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6", "type": "github" }, "original": { @@ -334,11 +334,11 @@ "null-ls-nvim-src": { "flake": false, "locked": { - "lastModified": 1678896738, - "narHash": "sha256-Ah8Wy1C3Cd75vw/8IRrYNZgSYXTgTxZwpABMb2LzW8Q=", + "lastModified": 1679325581, + "narHash": "sha256-ixhy8qgP2GEPqrMdI+GsHzeHxESwhRw6cjf5hcpwP1w=", "owner": "jose-elias-alvarez", "repo": "null-ls.nvim", - "rev": "2fcc10637b325e656d45a760901e1e05170e36c9", + "rev": "13dd1fc13063681ca7e039436c88f6eca7e3e937", "type": "github" }, "original": { @@ -349,11 +349,11 @@ }, "nur": { "locked": { - "lastModified": 1678915555, - "narHash": "sha256-U4BDXptYZH2j59syOxuAbkpioKxqW+bC3LbJK+Tofw8=", + "lastModified": 1679482366, + "narHash": "sha256-88K2ABCsdsVwq6Go/uEn/fds1fUeeeoixOALjrrUI0Q=", "owner": "nix-community", "repo": "nur", - "rev": "40cbb3e28ea69c29375f6e0d01988caf50244f1f", + "rev": "e9088dc6f9f289fbff984744ad04dccbd5c1f8ac", "type": "github" }, "original": { @@ -365,11 +365,11 @@ "nvim-lspconfig-src": { "flake": false, "locked": { - "lastModified": 1678883048, - "narHash": "sha256-D/KLRg2yenxBX+24njWg2c494hI3uKIcZGhQbk+jg1c=", + "lastModified": 1679319980, + "narHash": "sha256-UQ/Zng1/9rXRnQeAjemA21qfCltmZRq9QekQ0vGYlX8=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "63f4c0082f007d2356df4bc335f55e6d414da89c", + "rev": "0f94c5fded29c0024254259f3d8a0284bfb507ea", "type": "github" }, "original": { @@ -397,11 +397,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1678916699, - "narHash": "sha256-I1uXrvDGHDwv9k1shITQvIGGNCiB7TBeDHRC1cWWd7s=", + "lastModified": 1679482116, + "narHash": "sha256-SofmIKv/zGsocOBEbmzOraTE0GuLDjrJB2gZhKCz8ok=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "fa0644667ea7ee7a72efdb69c471de4953a11019", + "rev": "dbdbd71b41a3627e0f2784eff746ad4366e2a21c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0280f2d..812aa8d 100644 --- a/flake.nix +++ b/flake.nix @@ -201,6 +201,8 @@ buildInputs = with pkgs; [ git stylua nixfmt shfmt shellcheck ]; }; + test = pkgs.mkShell { buildInputs = with pkgs; [ age ]; }; + # Used for cloud and systems development and administration devops = pkgs.mkShell { buildInputs = with pkgs; [ diff --git a/modules/common/applications/kitty.nix b/modules/common/applications/kitty.nix index 95e67df..6e22e04 100644 --- a/modules/common/applications/kitty.nix +++ b/modules/common/applications/kitty.nix @@ -12,8 +12,11 @@ config = lib.mkIf (config.gui.enable && config.kitty.enable) { # Set the Rofi-Systemd terminal for viewing logs - environment.sessionVariables.ROFI_SYSTEMD_TERM = - lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty"; + # Using optionalAttrs because only available in NixOS + environment = { } // lib.attrsets.optionalAttrs + (builtins.hasAttr "sessionVariables" config.environment) { + sessionVariables.ROFI_SYSTEMD_TERM = "${pkgs.kitty}/bin/kitty"; + }; home-manager.users.${config.user} = { diff --git a/modules/common/default.nix b/modules/common/default.nix index fedb3ed..95bb732 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -44,11 +44,6 @@ default = true; }; }; - - # colorscheme = lib.mkOption { - # type = types.attrs; - # description = "Base16 color scheme"; - # }; homePath = lib.mkOption { type = lib.types.path; description = "Path of user's home directory."; @@ -57,7 +52,6 @@ else "/home/${config.user}"); }; - dotfilesPath = lib.mkOption { type = lib.types.path; description = "Path of dotfiles repository."; @@ -95,7 +89,8 @@ ]; # Scans and hard links identical files in the store - auto-optimise-store = true; + # Not working with macOS: https://github.com/NixOS/nix/issues/7273 + auto-optimise-store = lib.mkIf (!pkgs.stdenv.isDarwin) true; }; diff --git a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua index 57eb477..9c50a1d 100644 --- a/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua +++ b/modules/darwin/hammerspoon/Spoons/Launcher.spoon/init.lua @@ -90,6 +90,7 @@ function obj:init() self:switch("System Preferences.app") end) self.launcher:bind("", "R", function() + hs.console.clearConsole() hs.reload() end) self.launcher:bind("", "S", function() diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index a8e09aa..3b4ec9d 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -4,6 +4,10 @@ config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { + # Set the Rofi-Systemd terminal for viewing logs + environment.sessionVariables.ROFI_SYSTEMD_TERM = + lib.mkIf config.kitty.enable "${pkgs.kitty}/bin/kitty"; + home-manager.users.${config.user} = { home.packages = with pkgs; From f69d233c394eb9c997a6ea460537a746359578cb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:15:41 -0400 Subject: [PATCH 280/391] switch audio with rofi and add extraLib --- flake.nix | 1 + modules/darwin/utilities.nix | 17 ++--------------- modules/nixos/graphical/default.nix | 4 ++++ modules/nixos/graphical/i3.nix | 2 ++ modules/nixos/graphical/rofi.nix | 11 ++++++++++- modules/nixos/graphical/rofi/pulse-sink.sh | 15 +++++++++++++++ overlays/lib.nix | 16 ++++++++++++++++ 7 files changed, 50 insertions(+), 16 deletions(-) create mode 100755 modules/nixos/graphical/rofi/pulse-sink.sh create mode 100644 overlays/lib.nix diff --git a/flake.nix b/flake.nix index 812aa8d..a0a47f5 100644 --- a/flake.nix +++ b/flake.nix @@ -121,6 +121,7 @@ inputs.nur.overlay inputs.nix2vim.overlay (import ./overlays/neovim-plugins.nix inputs) + (import ./overlays/lib.nix) (import ./overlays/calibre-web.nix) ]; diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index 763dba7..1021ef6 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -1,19 +1,6 @@ { config, pkgs, lib, ... }: -let - - # Quickly package shell scripts with their dependencies - # From https://discourse.nixos.org/t/how-to-create-a-script-with-dependencies/7970/6 - mkScript = { name, file, env ? [ ] }: - pkgs.writeScriptBin name '' - for i in ${lib.concatStringsSep " " env}; do - export PATH="$i/bin:$PATH" - done - - exec ${pkgs.bash}/bin/bash ${file} $@ - ''; - -in { +{ home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin { @@ -32,7 +19,7 @@ in { consul noti # Create notifications programmatically ipcalc # Make IP network calculations - (mkScript { + (pkgs.extraLib.mkScript { name = "ocr"; file = ../../modules/common/shell/bash/scripts/ocr.sh; env = [ tesseract ]; diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix index 9d6c8e6..13c3b1a 100644 --- a/modules/nixos/graphical/default.nix +++ b/modules/nixos/graphical/default.nix @@ -17,6 +17,10 @@ type = lib.types.str; description = "Command to use for choosing windows"; }; + audioSwitchCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for switching audio sink"; + }; toggleBarCommand = lib.mkOption { type = lib.types.str; description = "Command to hide and show the status bar."; diff --git a/modules/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix index d41e3be..6874ba5 100644 --- a/modules/nixos/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -112,6 +112,8 @@ in { "exec --no-startup-id ${config.launcherCommand}"; "${modifier}+Shift+s" = "exec --no-startup-id ${config.systemdSearch}"; + "${modifier}+Shift+a" = + "exec --no-startup-id ${config.audioSwitchCommand}"; "Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; "${modifier}+Shift+c" = "reload"; "${modifier}+Shift+r" = "restart"; diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index 3b4ec9d..a0e75d6 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -155,7 +155,16 @@ altTabCommand = "${ config.home-manager.users.${config.user}.programs.rofi.finalPackage }/bin/rofi -show window -modi window"; - + audioSwitchCommand = "${ + (pkgs.extraLib.mkScript { + name = "switch-audio"; + file = ./rofi/pulse-sink.sh; + env = [ + pkgs.ponymix + config.home-manager.users.${config.user}.programs.rofi.finalPackage + ]; + }) + }/bin/switch-audio"; }; } diff --git a/modules/nixos/graphical/rofi/pulse-sink.sh b/modules/nixos/graphical/rofi/pulse-sink.sh new file mode 100755 index 0000000..1bb09c0 --- /dev/null +++ b/modules/nixos/graphical/rofi/pulse-sink.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Credit: https://gist.github.com/Nervengift/844a597104631c36513c + +sink=$( + ponymix -t sink list | + awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | + rofi -dmenu -p 'pulseaudio sink:' -location 6 -width 100 | + grep -Po '[0-9]+(?=:)' +) && + ponymix set-default -d "$sink" && + for input in $(ponymix list -t sink-input | grep -Po '[0-9]+(?=:)'); do + echo "$input -> $sink" + ponymix -t sink-input -d "$input" move "$sink" + done diff --git a/overlays/lib.nix b/overlays/lib.nix new file mode 100644 index 0000000..9e60c89 --- /dev/null +++ b/overlays/lib.nix @@ -0,0 +1,16 @@ +_final: prev: { + extraLib = prev.lib // { + + # Quickly package shell scripts with their dependencies + # From https://discourse.nixos.org/t/how-to-create-a-script-with-dependencies/7970/6 + mkScript = { name, file, env ? [ ] }: + prev.pkgs.writeScriptBin name '' + for i in ${prev.lib.concatStringsSep " " env}; do + export PATH="$i/bin:$PATH" + done + + exec ${prev.pkgs.bash}/bin/bash ${file} $@ + ''; + }; + +} From 47590abc3a6d9c4417028127ed7098d0c4e50bba Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:17:15 -0400 Subject: [PATCH 281/391] lazy evaluated let for rofi --- modules/nixos/graphical/rofi.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index a0e75d6..482a3be 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -1,6 +1,10 @@ { config, pkgs, lib, ... }: -{ +let + + rofi = config.home-manager.users.${config.user}.programs.rofi.finalPackage; + +in { config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { @@ -148,21 +152,14 @@ }; - launcherCommand = "${ - config.home-manager.users.${config.user}.programs.rofi.finalPackage - }/bin/rofi -show run -modi run"; + launcherCommand = "${rofi}/bin/rofi -show run -modi run"; systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; - altTabCommand = "${ - config.home-manager.users.${config.user}.programs.rofi.finalPackage - }/bin/rofi -show window -modi window"; + altTabCommand = "${rofi}/bin/rofi -show window -modi window"; audioSwitchCommand = "${ (pkgs.extraLib.mkScript { name = "switch-audio"; file = ./rofi/pulse-sink.sh; - env = [ - pkgs.ponymix - config.home-manager.users.${config.user}.programs.rofi.finalPackage - ]; + env = [ pkgs.ponymix rofi ]; }) }/bin/switch-audio"; }; From 514244476d4b0d43a62aebd5a8ff58da40770282 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:33:06 -0400 Subject: [PATCH 282/391] adjust rofi themes --- modules/nixos/graphical/rofi.nix | 2 +- modules/nixos/graphical/rofi/pulse-sink.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index 482a3be..26da4d3 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -152,7 +152,7 @@ in { }; - launcherCommand = "${rofi}/bin/rofi -show run -modi run"; + launcherCommand = "${rofi}/bin/rofi -modes drun -show drun"; systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; altTabCommand = "${rofi}/bin/rofi -show window -modi window"; audioSwitchCommand = "${ diff --git a/modules/nixos/graphical/rofi/pulse-sink.sh b/modules/nixos/graphical/rofi/pulse-sink.sh index 1bb09c0..8a8a009 100755 --- a/modules/nixos/graphical/rofi/pulse-sink.sh +++ b/modules/nixos/graphical/rofi/pulse-sink.sh @@ -5,7 +5,7 @@ sink=$( ponymix -t sink list | awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | - rofi -dmenu -p 'pulseaudio sink:' -location 6 -width 100 | + rofi -dmenu -p 'pulseaudio sink:' -location 6 -width 100 -theme-str 'inputbar { enabled: false; }' | grep -Po '[0-9]+(?=:)' ) && ponymix set-default -d "$sink" && From b06b6490f4b5a99b22d2f7b256cff3e7d4fc36e3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 8 Mar 2023 18:19:51 -0500 Subject: [PATCH 283/391] start working on readme table fill out readme table more readme links and move installation clean up add more flake comments hosts and modules readmes fix: macos readme link switch links to relative file --- README.md | 118 ++++++++++++++++--------------------------- docs/installation.md | 67 ++++++++++++++++++++++++ flake.nix | 15 ++++-- hosts/README.md | 10 ++++ modules/README.md | 8 +++ 5 files changed, 139 insertions(+), 79 deletions(-) create mode 100644 docs/installation.md create mode 100644 hosts/README.md create mode 100644 modules/README.md diff --git a/README.md b/README.md index 96a34e5..c35d99a 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,56 @@ hosts. They are organized and managed by [Nix](https://nixos.org), so some of the configuration may be difficult to translate to a non-Nix system. -However, some of the configurations are easier to lift directly: +## System Features -- [Neovim](https://github.com/nmasur/dotfiles/tree/master/modules/common/neovim/config) -- [Fish functions](https://github.com/nmasur/dotfiles/tree/master/modules/common/shell/fish/functions) -- [More fish aliases](https://github.com/nmasur/dotfiles/blob/master/modules/common/shell/fish/default.nix) -- [Git aliases](https://github.com/nmasur/dotfiles/blob/master/modules/common/shell/git.nix) -- [Hammerspoon](https://github.com/nmasur/dotfiles/tree/master/modules/darwin/hammerspoon) +| Feature | Program | Configuration | +| --- | --- | --- | +| OS | [NixOS](https://nixos.org) | [Link](./modules/nixos) | +| Display Server | [X11](https://www.x.org/wiki/) | [Link](./modules/nixos/graphical/xorg.nix) | +| Compositor | [Picom](https://github.com/yshui/picom) | [Link](./modules/nixos/graphical/picom.nix) | +| Window Manager | [i3](https://i3wm.org/) | [Link](./modules/nixos/graphical/i3.nix) | +| Panel | [Polybar](https://polybar.github.io/) | [Link](./modules/nixos/graphical/polybar.nix) | +| Font | [Victor Mono](https://rubjo.github.io/victor-mono/) | [Link](./modules/nixos/graphical/fonts.nix) | +| Launcher | [Rofi](https://github.com/davatorium/rofi) | [Link](./modules/nixos/graphical/rofi.nix) | -Try out my Neovim config (requires [nix](https://nixos.org/download.html)): +## User Features + +| Feature | Program | Configuration | +| --- | --- | --- | +| Dotfiles | [Home-Manager](https://github.com/nix-community/home-manager) | [Link](./modules/common) | +| Terminal | [Kitty](https://sw.kovidgoyal.net/kitty/) | [Link](./modules/common/applications/kitty.nix) | +| Shell | [Fish](https://fishshell.com/) | [Link](./modules/common/shell/fish) | +| Shell Prompt | [Starship](https://starship.rs/) | [Link](./modules/common/shell/starhip.nix) | +| Colorscheme | [Gruvbox](https://github.com/morhetz/gruvbox) | [Link](./colorscheme/gruvbox) | +| Wallpaper | [Road](https://gitlab.com/exorcist365/wallpapers/-/blob/master/gruvbox/road.jpg) | [Link](./hosts/tempest/default.nix) +| Text Editor | [Neovim](https://neovim.io/) | [Link](./modules/common/neovim/config) | +| Browser | [Firefox](https://www.mozilla.org/en-US/firefox/new/) | [Link](./modules/common/applications/firefox.nix) | +| E-Mail | [Aerc](https://aerc-mail.org/) | [Link](./modules/common/mail/aerc.nix) | +| File Manager | [Nautilus](https://wiki.gnome.org/action/show/Apps/Files) | [Link](./modules/common/applications/nautilus.nix) | +| PDF Reader | [Zathura](https://pwmt.org/projects/zathura/) | [Link](./modules/common/applications/media.nix) | +| Video Player | [mpv](https://mpv.io/) | [Link](./modules/common/applications/media.nix) | + +## macOS Features + +| Feature | Program | Configuration | +| --- | --- | --- | +| Keybinds | [Hammerspoon](https://www.hammerspoon.org/) | [Link](./modules/darwin/hammerspoon) | + +--- + +# Installation + +Click [here](./docs/installation.md) for detailed installation instructions. + +# Neovim + +Try out my Neovim config with nix: ```bash nix run github:nmasur/dotfiles#neovim ``` -Or build it as a package (requires [nix](https://nixos.org/download.html)): +Or build it as a package: ```bash nix build github:nmasur/dotfiles#neovim @@ -30,73 +65,6 @@ If you already have a Neovim configuration, you may need to move it out of `~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise both configs might conflict with each other. ---- - -# Full Installation - -## NixOS - From Live Disk - -Format drives and build system from any NixOS host, including the live -installer disk: - -**This will erase your drives; use at your own risk!** - -```bash -lsblk # Choose the disk you want to wipe -nix-shell -p nixVersions.stable -nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest -``` - -## NixOS - From Existing System - -If you're already running NixOS, you can switch to this configuration with the -following command: - -```bash -nix-shell -p nixVersions.stable -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#tempest -``` - -## Windows - From NixOS WSL - -After [installing NixOS on -WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to -the WSL configuration: - -``` -nix-shell -p nixVersions.stable -sudo nixos-rebuild switch --flake github:nmasur/dotfiles#hydra -``` - -You should also download the -[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip) -font and install it on Windows. Install [Alacritty](https://alacritty.org/) and -move the `windows/alacritty.yml` file to -`C:\Users\\AppData\Roaming\alacritty`. - -## macOS - -To get started on a bare macOS installation, first install Nix: - -```bash -sh -c "$(curl -L https://nixos.org/nix/install)" -``` - -Then use Nix to build nix-darwin: - -```bash -nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer -./result/bin/darwin-installer -``` - -Then switch to the macOS configuration: - -```bash -darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass -``` - ---- - # Flake Templates You can also use the [templates](./templates/) as flakes for starting new diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..739e7d6 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,67 @@ +[Back to README](../README.md) + +--- + +# Installation + +## NixOS - From Live Disk + +Format drives and build system from any NixOS host, including the live +installer disk: + +**This will erase your drives; use at your own risk!** + +```bash +lsblk # Choose the disk you want to wipe +nix-shell -p nixVersions.stable +nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest +``` + +## NixOS - From Existing System + +If you're already running NixOS, you can switch to this configuration with the +following command: + +```bash +nix-shell -p nixVersions.stable +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#tempest +``` + +## Windows - From NixOS WSL + +After [installing NixOS on +WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to +the WSL configuration: + +``` +nix-shell -p nixVersions.stable +sudo nixos-rebuild switch --flake github:nmasur/dotfiles#hydra +``` + +You should also download the +[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip) +font and install it on Windows. Install [Alacritty](https://alacritty.org/) and +move the `windows/alacritty.yml` file to +`C:\Users\\AppData\Roaming\alacritty`. + +## macOS + +To get started on a bare macOS installation, first install Nix: + +```bash +sh -c "$(curl -L https://nixos.org/nix/install)" +``` + +Then use Nix to build nix-darwin: + +```bash +nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer +./result/bin/darwin-installer +``` + +Then switch to the macOS configuration: + +```bash +darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass +``` + diff --git a/flake.nix b/flake.nix index a0a47f5..a2a464d 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,7 @@ # Used for Windows Subsystem for Linux compatibility wsl.url = "github:nix-community/NixOS-WSL"; - # Used for user packages + # Used for user packages and dotfiles home-manager = { url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = @@ -134,6 +134,8 @@ in rec { + # Contains my full system builds, including home-manager + # nixos-rebuild switch --flake .#tempest nixosConfigurations = { tempest = import ./hosts/tempest { inherit inputs globals overlays; }; hydra = import ./hosts/hydra { inherit inputs globals overlays; }; @@ -141,6 +143,8 @@ swan = import ./hosts/swan { inherit inputs globals overlays; }; }; + # Contains my full Mac system builds, including home-manager + # darwin-rebuild switch --flake .#lookingglass darwinConfigurations = { lookingglass = import ./hosts/lookingglass { inherit inputs globals overlays; }; @@ -155,23 +159,24 @@ darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home; }; - # Disk formatting + # Disk formatting, only used once diskoConfigurations = { root = import ./disks/root.nix; }; - # Package servers into images with a generator + # Other packages, such as system images or programs packages = forAllSystems (system: { + # Package servers into images with a generator aws = { "${system}" = import ./generators/aws { inherit inputs globals system overlays; }; }; - staff = { "${system}" = import ./generators/staff { inherit inputs globals system overlays; }; }; + # Package Neovim config into standalone package neovim = let pkgs = import nixpkgs { inherit system overlays; }; in import ./modules/common/neovim/package { inherit pkgs; @@ -181,6 +186,7 @@ }); + # Programs that can be run by calling this flake apps = forAllSystems (system: let pkgs = import nixpkgs { @@ -193,6 +199,7 @@ }; in import ./apps { inherit pkgs; }); + # Development environments devShells = forAllSystems (system: let pkgs = import nixpkgs { inherit system overlays; }; in { diff --git a/hosts/README.md b/hosts/README.md new file mode 100644 index 0000000..c68cef3 --- /dev/null +++ b/hosts/README.md @@ -0,0 +1,10 @@ +# Hosts + +| Host | Purpose | +| --- | --- | +| [flame](./flame/default.nix) | Oracle cloud server | +| [hydra](./hydra/default.nix) | WSL config | +| [lookingglass](./lookingglass/default.nix) | Work macOS | +| [swan](./swan/default.nix) | Home NAS and server | +| [tempest](./tempest/default.nix) | Desktop | + diff --git a/modules/README.md b/modules/README.md new file mode 100644 index 0000000..69c963d --- /dev/null +++ b/modules/README.md @@ -0,0 +1,8 @@ +# Modules + +| Module | Purpose | +| --- | --- | +| [common](./common/default.nix) | User programs and OS-agnostic configuration | +| [darwin](./darwin/default.nix) | macOS-specific configuration | +| [nixos](./nixos/default.nix) | NixOS-specific configuration | + From f9c09deb2a061a579f0b83c000492348e24bca3c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 24 Mar 2023 16:20:41 -0400 Subject: [PATCH 284/391] compile all grammars for nvim-treesitter --- flake.lock | 7 ++++--- flake.nix | 2 +- modules/common/neovim/config/syntax.nix | 12 +----------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 4d929fa..3fb2a47 100644 --- a/flake.lock +++ b/flake.lock @@ -397,15 +397,16 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1679482116, - "narHash": "sha256-SofmIKv/zGsocOBEbmzOraTE0GuLDjrJB2gZhKCz8ok=", + "lastModified": 1677248832, + "narHash": "sha256-4TmtrufxjVpnSNfFpn6GQStEhq3KQb3JfmfMEJnSI8k=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "dbdbd71b41a3627e0f2784eff746ad4366e2a21c", + "rev": "b401b7423d18c78371c5ff1a5f8d3c14292b2047", "type": "github" }, "original": { "owner": "nvim-treesitter", + "ref": "v0.8.5.2", "repo": "nvim-treesitter", "type": "github" } diff --git a/flake.nix b/flake.nix index a2a464d..c483b83 100644 --- a/flake.nix +++ b/flake.nix @@ -74,7 +74,7 @@ flake = false; }; nvim-treesitter-src = { - url = "github:nvim-treesitter/nvim-treesitter"; + url = "github:nvim-treesitter/nvim-treesitter/v0.8.5.2"; flake = false; }; telescope-nvim-src = { diff --git a/modules/common/neovim/config/syntax.nix b/modules/common/neovim/config/syntax.nix index 56b8529..6cf4c42 100644 --- a/modules/common/neovim/config/syntax.nix +++ b/modules/common/neovim/config/syntax.nix @@ -1,17 +1,7 @@ { pkgs, ... }: { plugins = [ - (pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins: - with pkgs.tree-sitter-grammars; [ - tree-sitter-hcl - tree-sitter-python - tree-sitter-lua - tree-sitter-nix - tree-sitter-fish - tree-sitter-toml - tree-sitter-yaml - tree-sitter-json - ])) + pkgs.vimPlugins.nvim-treesitter.withAllGrammars pkgs.vimPlugins.vim-matchup # Better % jumping in languages pkgs.vimPlugins.nginx-vim pkgs.vimPlugins.vim-helm From 57de089bafcd29db0acf9827b898896552ce9ed7 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:51:20 -0400 Subject: [PATCH 285/391] add mpv delete file script --- modules/common/applications/media.nix | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/common/applications/media.nix b/modules/common/applications/media.nix index a5e4452..994f500 100644 --- a/modules/common/applications/media.nix +++ b/modules/common/applications/media.nix @@ -22,7 +22,28 @@ enable = true; bindings = { }; config = { image-display-duration = 2; }; - scripts = [ pkgs.mpvScripts.autoload ]; + scripts = [ + + # Automatically load playlist entries before and after current file + pkgs.mpvScripts.autoload + + # Delete current file after quitting + (pkgs.stdenv.mkDerivation rec { + pname = "mpv-delete-file"; + version = "0.1"; # made-up + src = pkgs.fetchFromGitHub { + owner = "zenyd"; + repo = "mpv-scripts"; + rev = "19ea069abcb794d1bf8fac2f59b50d71ab992130"; + sha256 = "sha256-OBCuzCtgfSwj0i/rBNranuu4LRc47jObwQIJgQQoerg="; + } + "/delete_file.lua"; + dontBuild = true; + dontUnpack = true; + installPhase = + "install -Dm644 ${src} $out/share/mpv/scripts/delete_file.lua"; + passthru.scriptName = "delete_file.lua"; + }) + ]; }; # Set default for opening PDFs From 76c80dd31dfce0423c9794fac50a26475f892818 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 26 Mar 2023 20:52:28 +0000 Subject: [PATCH 286/391] fix: samba don't use force group --- modules/nixos/services/samba.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/nixos/services/samba.nix b/modules/nixos/services/samba.nix index f4c3994..435fd79 100644 --- a/modules/nixos/services/samba.nix +++ b/modules/nixos/services/samba.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: { +{ config, lib, ... }: { options = { samba.enable = lib.mkEnableOption "Enable Samba sharing."; }; @@ -12,8 +12,6 @@ browseable = "yes"; "read only" = "no"; "guest ok" = "no"; - "force user" = config.user; - "force group" = config.user; comment = "NAS"; }; }; From 8e32c16fd32ebac67a654a82b1a6af7f271e798e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 27 Mar 2023 13:45:23 -0400 Subject: [PATCH 287/391] try to fix timezone failure --- modules/nixos/system/timezone.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/nixos/system/timezone.nix b/modules/nixos/system/timezone.nix index a47ed03..d7feea6 100644 --- a/modules/nixos/system/timezone.nix +++ b/modules/nixos/system/timezone.nix @@ -14,6 +14,10 @@ services.geoclue2.appConfig.localtimed.isSystem = true; services.geoclue2.appConfig.localtimed.isAllowed = true; + # Fix "Failed to set timezone" + # https://github.com/NixOS/nixpkgs/issues/68489#issuecomment-1484030107 + services.geoclue2.enableDemoAgent = lib.mkForce true; + }; } From 59824adb3a6390abba5559265a79db261dbd24a4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 30 Mar 2023 10:24:19 -0400 Subject: [PATCH 288/391] much improved speed in fzf project switcher --- modules/common/shell/fzf.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/common/shell/fzf.nix b/modules/common/shell/fzf.nix index 9f21f47..1f9819b 100644 --- a/modules/common/shell/fzf.nix +++ b/modules/common/shell/fzf.nix @@ -13,9 +13,8 @@ fd \ --search-path $HOME/dev \ --type directory \ - --hidden \ - "^.git\$" \ - | xargs dirname \ + --exact-depth 2 \ + | sed 's/\\/$//' \ | fzf \ --delimiter '/' \ --with-nth 6.. \ From 2e3c376d73ce5be56f475ae5a49cadcad1b1889d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 31 Mar 2023 12:39:10 -0400 Subject: [PATCH 289/391] add prs shortcut --- modules/common/shell/github.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/common/shell/github.nix b/modules/common/shell/github.nix index 4487f6f..dbf5267 100644 --- a/modules/common/shell/github.nix +++ b/modules/common/shell/github.nix @@ -19,6 +19,9 @@ grf = "gh run view --log-failed"; grl = "gh run view --log"; ghpr = "gh pr create && sleep 3 && gh run watch"; + + # https://github.com/cli/cli/discussions/4067 + prs = "gh search prs --state=open --review-requested=@me"; }; functions = { repos = { From afedfcf1875187bbb5dec8931e31afb2586d660b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Apr 2023 09:41:45 -0400 Subject: [PATCH 290/391] i3 focus or run browser and mail --- modules/common/applications/firefox.nix | 18 ++++++++++++++++++ modules/common/mail/aerc.nix | 12 +++++++++++- modules/nixos/graphical/i3.nix | 6 +++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/modules/common/applications/firefox.nix b/modules/common/applications/firefox.nix index 4b809c0..f2a9d65 100644 --- a/modules/common/applications/firefox.nix +++ b/modules/common/applications/firefox.nix @@ -157,6 +157,24 @@ }; }; + + xsession.windowManager.i3.config.keybindings = + lib.mkIf pkgs.stdenv.isLinux { + "${ + config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier + }+Shift+b" = "exec ${ + # Don't name the script `firefox` or it will affect grep + builtins.toString (pkgs.writeShellScript "focus-ff.sh" '' + count=$(ps aux | grep -c firefox) + if [ "$count" -eq 1 ]; then + i3-msg "exec --no-startup-id firefox" + sleep 0.5 + fi + i3-msg "[class=firefox] focus" + '') + }"; + }; + }; }; diff --git a/modules/common/mail/aerc.nix b/modules/common/mail/aerc.nix index bfd0241..913cc21 100644 --- a/modules/common/mail/aerc.nix +++ b/modules/common/mail/aerc.nix @@ -191,7 +191,17 @@ lib.mkIf pkgs.stdenv.isLinux { "${ config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier - }+Shift+e" = "exec --no-startup-id kitty aerc"; + }+Shift+e" = "exec ${ + # Don't name the script `aerc` or it will affect grep + builtins.toString (pkgs.writeShellScript "focus-mail.sh" '' + count=$(ps aux | grep -c aerc) + if [ "$count" -eq 1 ]; then + i3-msg "exec --no-startup-id kitty --class aerc aerc" + sleep 0.25 + fi + i3-msg "[class=aerc] focus" + '') + }"; }; programs.fish.shellAbbrs = { ae = "aerc"; }; diff --git a/modules/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix index 6874ba5..f81379e 100644 --- a/modules/nixos/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -39,7 +39,11 @@ in { modifier = modifier; assigns = { "${ws1}" = [{ class = "Firefox"; }]; - "${ws2}" = [{ class = "kitty"; }]; + "${ws2}" = [ + { class = "kitty"; } + { class = "aerc"; } + { class = "obsidian"; } + ]; "${ws3}" = [{ class = "discord"; }]; "${ws4}" = [{ class = "Steam"; }]; }; From ff4db1463ede86558243056c6521f23c665edab5 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Apr 2023 20:21:26 -0400 Subject: [PATCH 291/391] finally fix sleep on tempest --- modules/nixos/hardware/sleep.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/nixos/hardware/sleep.nix b/modules/nixos/hardware/sleep.nix index f5db8a6..96d2dd8 100644 --- a/modules/nixos/hardware/sleep.nix +++ b/modules/nixos/hardware/sleep.nix @@ -4,17 +4,18 @@ # Prevent wake from keyboard powerManagement.powerDownCommands = '' - # for power in /sys/bus/usb/devices/*/power; do echo disabled > ''${power}/wakeup; done + set +e - # AMD issue: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Instantaneous_wakeups_from_suspend - for power in /sys/bus/i2c/devices/i2c-*/device/power; do echo disabled > ''${power}/wakeup; done + for power in /sys/bus/i2c/devices/i2c-*/device/power; do echo disabled > ''${power}/wakeup || true; done + for power in /sys/bus/usb/devices/1-*/device/power; do echo disabled > ''${power}/wakeup || true; done + + # Fix for Gigabyte motherboard + # /r/archlinux/comments/y7b97e/my_computer_wakes_up_immediately_after_i_suspend/isu99sr/ + echo GPP0 > /proc/acpi/wakeup + + set -e ''; - # From here: https://www.reddit.com/r/NixOS/comments/wcu34f/how_would_i_do_this_in_nix/ - # services.udev.extraRules = '' - # ACTION=="add", SUBSYSTEM=="i2c", ATTRS{idVendor}=="", ATTRS{idProduct}=="" RUN+="${pkgs.bash}/bin/bash -c 'echo disabled > /sys/bus/i2c/devices/i2c-*/power/wakeup'" - # ''; - }; } From a13083a264f3fa7ec9db415ff3e9be25a5aa82e8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 08:22:28 -0400 Subject: [PATCH 292/391] now really fix sleep --- modules/nixos/hardware/sleep.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/nixos/hardware/sleep.nix b/modules/nixos/hardware/sleep.nix index 96d2dd8..205f737 100644 --- a/modules/nixos/hardware/sleep.nix +++ b/modules/nixos/hardware/sleep.nix @@ -7,7 +7,7 @@ set +e for power in /sys/bus/i2c/devices/i2c-*/device/power; do echo disabled > ''${power}/wakeup || true; done - for power in /sys/bus/usb/devices/1-*/device/power; do echo disabled > ''${power}/wakeup || true; done + for power in /sys/bus/usb/devices/1-*/power; do echo disabled > ''${power}/wakeup || true; done # Fix for Gigabyte motherboard # /r/archlinux/comments/y7b97e/my_computer_wakes_up_immediately_after_i_suspend/isu99sr/ @@ -16,6 +16,11 @@ set -e ''; + services.udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="disabled" + ACTION=="add", SUBSYSTEM=="i2c", ATTR{power/wakeup}="disabled" + ''; + }; } From d6611ca7a20c172371503f35a7cd0d81a53662e9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 12:25:33 -0400 Subject: [PATCH 293/391] rofi power menu --- modules/nixos/graphical/default.nix | 4 ++ modules/nixos/graphical/i3.nix | 2 + modules/nixos/graphical/rofi.nix | 14 ++++- modules/nixos/graphical/rofi/power.nix | 58 +++++++++++++++++ modules/nixos/graphical/rofi/rofi-prompt.sh | 44 +++++++++++++ .../nixos/graphical/rofi/themes/common.rasi | 62 +++++++++++++++++++ .../nixos/graphical/rofi/themes/launcher.rasi | 3 + .../nixos/graphical/rofi/themes/power.rasi | 1 + .../nixos/graphical/rofi/themes/prompt.rasi | 49 +++++++++++++++ 9 files changed, 235 insertions(+), 2 deletions(-) create mode 100755 modules/nixos/graphical/rofi/power.nix create mode 100755 modules/nixos/graphical/rofi/rofi-prompt.sh create mode 100644 modules/nixos/graphical/rofi/themes/common.rasi create mode 100644 modules/nixos/graphical/rofi/themes/launcher.rasi create mode 100644 modules/nixos/graphical/rofi/themes/power.rasi create mode 100644 modules/nixos/graphical/rofi/themes/prompt.rasi diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix index 13c3b1a..a2927bd 100644 --- a/modules/nixos/graphical/default.nix +++ b/modules/nixos/graphical/default.nix @@ -25,6 +25,10 @@ type = lib.types.str; description = "Command to hide and show the status bar."; }; + powerCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for power options menu"; + }; wallpaper = lib.mkOption { type = lib.types.path; description = "Wallpaper background image file"; diff --git a/modules/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix index f81379e..a861533 100644 --- a/modules/nixos/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -119,6 +119,8 @@ in { "${modifier}+Shift+a" = "exec --no-startup-id ${config.audioSwitchCommand}"; "Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; + "${modifier}+Shift+period" = + "exec --no-startup-id ${config.powerCommand}"; "${modifier}+Shift+c" = "reload"; "${modifier}+Shift+r" = "restart"; "${modifier}+Shift+q" = '' diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index 26da4d3..396219d 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -6,6 +6,8 @@ let in { + imports = [ ./rofi/power.nix ]; + config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { # Set the Rofi-Systemd terminal for viewing logs @@ -78,7 +80,7 @@ in { placeholder-color = mkLiteral config.theme.colors.base03; expand = true; horizontal-align = "0"; - placeholder = "Launch Program"; + placeholder = ""; padding = mkLiteral "0px 0px 0px 5px"; blink = true; }; @@ -147,12 +149,20 @@ in { show-icons = true; kb-cancel = "Escape,Super+space"; modi = "window,run,ssh,emoji,calc,systemd"; + sort = true; + # levenshtein-sort = true; }; }; + home.file.".local/share/rofi/themes" = { + recursive = true; + source = ./rofi/themes; + }; + }; - launcherCommand = "${rofi}/bin/rofi -modes drun -show drun"; + launcherCommand = '' + ${rofi}/bin/rofi -modes drun -show drun -theme-str '@import "launcher.rasi"' ''; systemdSearch = "${pkgs.rofi-systemd}/bin/rofi-systemd"; altTabCommand = "${rofi}/bin/rofi -show window -modi window"; audioSwitchCommand = "${ diff --git a/modules/nixos/graphical/rofi/power.nix b/modules/nixos/graphical/rofi/power.nix new file mode 100755 index 0000000..9c71802 --- /dev/null +++ b/modules/nixos/graphical/rofi/power.nix @@ -0,0 +1,58 @@ +{ config, pkgs, ... }: +let + + rofi = config.home-manager.users.${config.user}.programs.rofi.finalPackage; + +in { + + # Adapted from: + # https://gitlab.com/vahnrr/rofi-menus/-/blob/b1f0e8a676eda5552e27ef631b0d43e660b23b8e/scripts/rofi-power + # A rofi powered menu to execute power related action. + + config.powerCommand = builtins.toString (pkgs.writeShellScript "powermenu" '' + power_off='' + reboot='' + lock='' + suspend='鈴' + log_out='' + + chosen=$(printf '%s;%s;%s;%s;%s\n' \ + "$power_off" \ + "$reboot" \ + "$lock" \ + "$suspend" \ + "$log_out" \ + | ${rofi}/bin/rofi \ + -theme-str '@import "power.rasi"' \ + -dmenu \ + -sep ';' \ + -selected-row 2) + + case "$chosen" in + "$power_off") + ${ + builtins.toString ./rofi-prompt.sh + } 'Shutdown?' && doas shutdown now + ;; + + "$reboot") + ${builtins.toString ./rofi-prompt.sh} 'Reboot?' && doas reboot + ;; + + "$lock") + ${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span + ;; + + "$suspend") + systemctl suspend + ;; + + "$log_out") + ${builtins.toString ./rofi-prompt.sh} 'Logout?' && i3-msg exit + ;; + + *) exit 1 ;; + esac + ''); + +} diff --git a/modules/nixos/graphical/rofi/rofi-prompt.sh b/modules/nixos/graphical/rofi/rofi-prompt.sh new file mode 100755 index 0000000..fea1bfe --- /dev/null +++ b/modules/nixos/graphical/rofi/rofi-prompt.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env sh + +# Credit: https://gitlab.com/vahnrr/rofi-menus/-/blob/b1f0e8a676eda5552e27ef631b0d43e660b23b8e/scripts/rofi-prompt + +# Rofi powered menu to prompt a message and get a yes/no answer. +# Uses: rofi + +yes='Confirm' +no='Cancel' +query='Are you sure?' + +while [ $# -ne 0 ]; do + case "$1" in + -y | --yes) + [ -n "$2" ] && yes="$2" || yes='' + shift + ;; + + -n | --no) + [ -n "$2" ] && no="$2" || no='' + shift + ;; + + -q | --query) + [ -n "$2" ] && query="$2" + shift + ;; + esac + shift +done + +chosen=$(printf '%s;%s\n' "$yes" "$no" | + rofi -theme-str '@import "prompt.rasi"' \ + -p "$query" \ + -dmenu \ + -sep ';' \ + -a 0 \ + -u 1 \ + -selected-row 1) + +case "$chosen" in + "$yes") exit 0 ;; + *) exit 1 ;; +esac diff --git a/modules/nixos/graphical/rofi/themes/common.rasi b/modules/nixos/graphical/rofi/themes/common.rasi new file mode 100644 index 0000000..8e5ee97 --- /dev/null +++ b/modules/nixos/graphical/rofi/themes/common.rasi @@ -0,0 +1,62 @@ +/** + * Allows to change the settings of every menu simply by editing this file + * https://gitlab.com/vahnrr/rofi-menus/-/blob/b1f0e8a676eda5552e27ef631b0d43e660b23b8e/themes/shared/settings.rasi + */ + +* { + /* General */ + font: "Hack Nerd Font 60"; + + /* option menus: i3-layout, music, power and screenshot + * + * Values bellow are 'no-padding' ones for a size 60 (@icon-font) font, played + * around using this character: ■ + * We then add add 100 actual padding around the icons. + * -12px 0px -19px -96px */ + option-element-padding: 1% 1% 1% 1%; + option-5-window-padding: 4% 4%; + option-5-listview-spacing: 15px; + + prompt-text-font: "Hack Nerd Font 18"; + prompt-window-height: 300px; + prompt-window-width: 627px; + prompt-window-border: 2px; + prompt-prompt-padding: 20px 30px; + prompt-prompt-margin: 8px; + prompt-listview-padding: 60px 114px 0px 114px; + /* Values bellow are 'no-padding' ones for a size 18 (@prompt-text-font) font, + * played around using this character: ■ + * We then add add 30 actual padding around the text. + * -4px -1px -6px -28px */ + prompt-element-padding: 26px 29px 24px 2px; + + vpn-textbox-prompt-colon-padding: @network-textbox-prompt-colon-padding; +} + +#window { + width: 980px; + height: 230px; +} + +/** + * Settings used in every rofi option menu: + */ +#window { + children: [ horibox ]; +} +#horibox { + children: [ listview ]; +} +#listview { + layout: horizontal; +} +element { + padding: 40px 68px 43px 30px; +} +#window { + padding: 20px; +} +#listview { + spacing: 10px; + lines: 5; +} diff --git a/modules/nixos/graphical/rofi/themes/launcher.rasi b/modules/nixos/graphical/rofi/themes/launcher.rasi new file mode 100644 index 0000000..2818047 --- /dev/null +++ b/modules/nixos/graphical/rofi/themes/launcher.rasi @@ -0,0 +1,3 @@ +#entry { + placeholder: "Launch Program"; +} diff --git a/modules/nixos/graphical/rofi/themes/power.rasi b/modules/nixos/graphical/rofi/themes/power.rasi new file mode 100644 index 0000000..abe5b23 --- /dev/null +++ b/modules/nixos/graphical/rofi/themes/power.rasi @@ -0,0 +1 @@ +@import "common.rasi" diff --git a/modules/nixos/graphical/rofi/themes/prompt.rasi b/modules/nixos/graphical/rofi/themes/prompt.rasi new file mode 100644 index 0000000..63ef1c6 --- /dev/null +++ b/modules/nixos/graphical/rofi/themes/prompt.rasi @@ -0,0 +1,49 @@ +/** + * This theme is intended for a 2 items option menu with a headerbar. + * https://gitlab.com/vahnrr/rofi-menus/-/blob/b1f0e8a676eda5552e27ef631b0d43e660b23b8e/themes/prompt.rasi + */ +@import "common.rasi" +* { + font: @text-font; +} +#window { + height: @prompt-window-height; + width: @prompt-window-width; + children: [ inputbar, horibox ]; + border: @prompt-window-border; + border-color: @accent; +} +#inputbar { + enabled: false; +} +#prompt { + padding: @prompt-prompt-padding; + margin: @prompt-prompt-margin; + background-color: @accent; + text-color: @background-light; +} +#listview { + padding: @prompt-listview-padding; + spacing: @option-5-listview-spacing; + lines: 2; +} +#element { + font: @prompt-text-font; + padding: @prompt-element-padding; +} +element.alternate.active, +element.normal.active, +element.alternate.urgent, +element.normal.urgent { + background-color: @background-light; + text-color: @foreground; +} +element.selected.urgent { + background-color: @off; + text-color: @background; +} +element.selected.active { + background-color: @on; + text-color: @background; +} + From 8283480fd1ade430fe2829e63cfe45b4ab3d268b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 15:52:45 -0400 Subject: [PATCH 294/391] rofi brightness menu --- modules/nixos/graphical/default.nix | 4 ++ modules/nixos/graphical/i3.nix | 2 + modules/nixos/graphical/rofi.nix | 2 +- modules/nixos/graphical/rofi/brightness.nix | 49 +++++++++++++++++++ modules/nixos/graphical/rofi/brightness.sh | 10 ---- modules/nixos/graphical/rofi/power.nix | 5 +- modules/nixos/graphical/rofi/rofi-prompt.sh | 3 ++ .../graphical/rofi/themes/brightness.rasi | 6 +++ .../nixos/graphical/rofi/themes/common.rasi | 5 -- .../nixos/graphical/rofi/themes/power.rasi | 5 ++ 10 files changed, 74 insertions(+), 17 deletions(-) create mode 100755 modules/nixos/graphical/rofi/brightness.nix delete mode 100755 modules/nixos/graphical/rofi/brightness.sh create mode 100644 modules/nixos/graphical/rofi/themes/brightness.rasi diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix index a2927bd..4e2173e 100644 --- a/modules/nixos/graphical/default.nix +++ b/modules/nixos/graphical/default.nix @@ -21,6 +21,10 @@ type = lib.types.str; description = "Command to use for switching audio sink"; }; + brightnessCommand = lib.mkOption { + type = lib.types.str; + description = "Command to use for adjusting brightness"; + }; toggleBarCommand = lib.mkOption { type = lib.types.str; description = "Command to hide and show the status bar."; diff --git a/modules/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix index a861533..53edb05 100644 --- a/modules/nixos/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -121,6 +121,8 @@ in { "Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; "${modifier}+Shift+period" = "exec --no-startup-id ${config.powerCommand}"; + "${modifier}+Shift+m" = + "exec --no-startup-id ${config.brightnessCommand}"; "${modifier}+Shift+c" = "reload"; "${modifier}+Shift+r" = "restart"; "${modifier}+Shift+q" = '' diff --git a/modules/nixos/graphical/rofi.nix b/modules/nixos/graphical/rofi.nix index 396219d..ed9d32a 100644 --- a/modules/nixos/graphical/rofi.nix +++ b/modules/nixos/graphical/rofi.nix @@ -6,7 +6,7 @@ let in { - imports = [ ./rofi/power.nix ]; + imports = [ ./rofi/power.nix ./rofi/brightness.nix ]; config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { diff --git a/modules/nixos/graphical/rofi/brightness.nix b/modules/nixos/graphical/rofi/brightness.nix new file mode 100755 index 0000000..351a9b8 --- /dev/null +++ b/modules/nixos/graphical/rofi/brightness.nix @@ -0,0 +1,49 @@ +{ config, pkgs, ... }: +let + + rofi = config.home-manager.users.${config.user}.programs.rofi.finalPackage; + +in { + + # Adapted from: + # A rofi powered menu to execute brightness choices. + + config.brightnessCommand = builtins.toString + (pkgs.writeShellScript "brightness" '' + + dimmer="" + medium="" + brighter="" + + chosen=$(printf '%s;%s;%s\n' \ + "$dimmer" \ + "$medium" \ + "$brighter" \ + | ${rofi}/bin/rofi \ + -theme-str '@import "brightness.rasi"' \ + -hover-select \ + -me-select-entry ''' \ + -me-accept-entry MousePrimary \ + -dmenu \ + -sep ';' \ + -selected-row 1) + + case "$chosen" in + "$dimmer") + ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 25; ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 25 + ;; + + "$medium") + ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 75; ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 75 + ;; + + "$brighter") + ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 100; ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 100 + ;; + + *) exit 1 ;; + esac + + ''); + +} diff --git a/modules/nixos/graphical/rofi/brightness.sh b/modules/nixos/graphical/rofi/brightness.sh deleted file mode 100755 index 977f433..0000000 --- a/modules/nixos/graphical/rofi/brightness.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# THEME="$HOME/.config/rofi/config.rasi" - -ICON_UP="" -ICON_DOWN="" -ICON_OPT="" -options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN" -chosen="$(echo -e "$options" | rofi -theme-str 'listview { layout:horizontal; }' -dmenu)" -echo "$chosen" diff --git a/modules/nixos/graphical/rofi/power.nix b/modules/nixos/graphical/rofi/power.nix index 9c71802..ea61b2e 100755 --- a/modules/nixos/graphical/rofi/power.nix +++ b/modules/nixos/graphical/rofi/power.nix @@ -23,7 +23,10 @@ in { "$suspend" \ "$log_out" \ | ${rofi}/bin/rofi \ - -theme-str '@import "power.rasi"' \ + -theme-str '@import "power.rasi"' \ + -hover-select \ + -me-select-entry ''' \ + -me-accept-entry MousePrimary \ -dmenu \ -sep ';' \ -selected-row 2) diff --git a/modules/nixos/graphical/rofi/rofi-prompt.sh b/modules/nixos/graphical/rofi/rofi-prompt.sh index fea1bfe..f304b4e 100755 --- a/modules/nixos/graphical/rofi/rofi-prompt.sh +++ b/modules/nixos/graphical/rofi/rofi-prompt.sh @@ -31,6 +31,9 @@ done chosen=$(printf '%s;%s\n' "$yes" "$no" | rofi -theme-str '@import "prompt.rasi"' \ + -hover-select \ + -me-select-entry '' \ + -me-accept-entry MousePrimary \ -p "$query" \ -dmenu \ -sep ';' \ diff --git a/modules/nixos/graphical/rofi/themes/brightness.rasi b/modules/nixos/graphical/rofi/themes/brightness.rasi new file mode 100644 index 0000000..9c45755 --- /dev/null +++ b/modules/nixos/graphical/rofi/themes/brightness.rasi @@ -0,0 +1,6 @@ +@import "common.rasi" + +#window { + width: 605px; + height: 230px; +} diff --git a/modules/nixos/graphical/rofi/themes/common.rasi b/modules/nixos/graphical/rofi/themes/common.rasi index 8e5ee97..bc3a265 100644 --- a/modules/nixos/graphical/rofi/themes/common.rasi +++ b/modules/nixos/graphical/rofi/themes/common.rasi @@ -33,11 +33,6 @@ vpn-textbox-prompt-colon-padding: @network-textbox-prompt-colon-padding; } -#window { - width: 980px; - height: 230px; -} - /** * Settings used in every rofi option menu: */ diff --git a/modules/nixos/graphical/rofi/themes/power.rasi b/modules/nixos/graphical/rofi/themes/power.rasi index abe5b23..719783c 100644 --- a/modules/nixos/graphical/rofi/themes/power.rasi +++ b/modules/nixos/graphical/rofi/themes/power.rasi @@ -1 +1,6 @@ @import "common.rasi" + +#window { + width: 980px; + height: 230px; +} From 985b8bf13bc3cd6e891609de28200ed6aa430d74 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 16:53:01 -0400 Subject: [PATCH 295/391] polybar audio and power buttons also switched from systemd because it breaks rofi --- modules/nixos/graphical/polybar.nix | 11 +++++++++-- modules/nixos/graphical/rofi/pulse-sink.sh | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/nixos/graphical/polybar.nix b/modules/nixos/graphical/polybar.nix index 2befe82..9ed48ff 100644 --- a/modules/nixos/graphical/polybar.nix +++ b/modules/nixos/graphical/polybar.nix @@ -36,7 +36,7 @@ module-margin = 1; modules-left = "i3"; modules-center = "xwindow"; - modules-right = "pulseaudio date"; + modules-right = "pulseaudio date power"; cursor-click = "pointer"; cursor-scroll = "ns-resize"; enable-ipc = true; @@ -115,6 +115,7 @@ ramp-volume-0 = ""; ramp-volume-1 = "墳"; ramp-volume-2 = ""; + click-right = config.audioSwitchCommand; }; # "module/xkeyboard" = { # type = "internal/xkeyboard"; @@ -166,6 +167,12 @@ label-foreground = config.theme.colors.base0A; # format-background = colors.background; }; + "module/power" = { + type = "custom/text"; + content = "  "; + click-left = config.powerCommand; + content-foreground = config.theme.colors.base04; + }; "settings" = { screenchange-reload = true; pseudo-transparency = false; @@ -174,7 +181,7 @@ }; xsession.windowManager.i3.config.startup = [{ - command = "systemctl --user restart polybar"; + command = "pkill polybar; polybar -r main"; always = true; notification = false; }]; diff --git a/modules/nixos/graphical/rofi/pulse-sink.sh b/modules/nixos/graphical/rofi/pulse-sink.sh index 8a8a009..de6d9f8 100755 --- a/modules/nixos/graphical/rofi/pulse-sink.sh +++ b/modules/nixos/graphical/rofi/pulse-sink.sh @@ -5,7 +5,14 @@ sink=$( ponymix -t sink list | awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | - rofi -dmenu -p 'pulseaudio sink:' -location 6 -width 100 -theme-str 'inputbar { enabled: false; }' | + rofi \ + -dmenu \ + -p 'pulseaudio sink:' \ + -width 100 \ + -hover-select \ + -me-select-entry '' \ + -me-accept-entry MousePrimary \ + -theme-str 'inputbar { enabled: false; }' | grep -Po '[0-9]+(?=:)' ) && ponymix set-default -d "$sink" && From 49c2c013a23e804d9829660a1b9be767eca42f34 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:46:22 -0400 Subject: [PATCH 296/391] update polybar spacing --- modules/nixos/graphical/polybar.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/graphical/polybar.nix b/modules/nixos/graphical/polybar.nix index 9ed48ff..155f07e 100644 --- a/modules/nixos/graphical/polybar.nix +++ b/modules/nixos/graphical/polybar.nix @@ -161,7 +161,7 @@ "module/date" = { type = "internal/date"; interval = 1; - date = "%d %b %l:%M %p"; + date = "%d %b %l:%M %p"; date-alt = "%Y-%m-%d %H:%M:%S"; label = "%date%"; label-foreground = config.theme.colors.base0A; From e349ac35b8f9aa1c35c83a1240ad82ad20e44206 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:47:06 -0400 Subject: [PATCH 297/391] fix: flake app for rebuilds --- apps/rebuild.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/rebuild.nix b/apps/rebuild.nix index 9d04bdb..973be25 100644 --- a/apps/rebuild.nix +++ b/apps/rebuild.nix @@ -6,9 +6,9 @@ echo ${pkgs.system} SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"} if [ "$SYSTEM" == "darwin" ]; then - darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass + sudo darwin-rebuild switch --flake ${builtins.toString ../.} else - nixos-rebuild switch --flake github:nmasur/dotfiles + doas nixos-rebuild switch --flake ${builtins.toString ../.} fi ''); From 0833a0009c7073814b921f24540fb7545fa5264d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 19:19:40 -0400 Subject: [PATCH 298/391] enable dunst notifications also rebuilds with shortcuts --- modules/nixos/graphical/default.nix | 11 ++++++++-- modules/nixos/graphical/dunst.nix | 31 +++++++++++++++++++++++++++++ modules/nixos/graphical/fonts.nix | 1 + modules/nixos/graphical/i3.nix | 4 ++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 modules/nixos/graphical/dunst.nix diff --git a/modules/nixos/graphical/default.nix b/modules/nixos/graphical/default.nix index 4e2173e..67f2cf3 100644 --- a/modules/nixos/graphical/default.nix +++ b/modules/nixos/graphical/default.nix @@ -1,7 +1,14 @@ { lib, ... }: { - imports = - [ ./xorg.nix ./fonts.nix ./i3.nix ./polybar.nix ./picom.nix ./rofi.nix ]; + imports = [ + ./dunst.nix + ./fonts.nix + ./i3.nix + ./picom.nix + ./polybar.nix + ./rofi.nix + ./xorg.nix + ]; options = { diff --git a/modules/nixos/graphical/dunst.nix b/modules/nixos/graphical/dunst.nix new file mode 100644 index 0000000..fa79e2e --- /dev/null +++ b/modules/nixos/graphical/dunst.nix @@ -0,0 +1,31 @@ +{ config, ... }: + +{ + + config = { + + home-manager.users.${config.user}.services.dunst = { + enable = true; + settings = { + global = { + width = 300; + height = 200; + offset = "30x50"; + origin = "top-right"; + transparency = 0; + padding = 20; + horizontal_padding = 20; + frame_color = config.theme.colors.base03; + }; + + urgency_normal = { + background = config.theme.colors.base00; + foreground = config.theme.colors.base05; + timeout = 10; + }; + }; + }; + + }; + +} diff --git a/modules/nixos/graphical/fonts.nix b/modules/nixos/graphical/fonts.nix index 9fb8191..c081450 100644 --- a/modules/nixos/graphical/fonts.nix +++ b/modules/nixos/graphical/fonts.nix @@ -22,6 +22,7 @@ in { programs.rofi.font = "Hack Nerd Font 14"; programs.alacritty.settings.font.normal.family = fontName; programs.kitty.font.name = fontName; + services.dunst.settings.global.font = "Hack Nerd Font 14"; }; }; diff --git a/modules/nixos/graphical/i3.nix b/modules/nixos/graphical/i3.nix index 53edb05..9956adf 100644 --- a/modules/nixos/graphical/i3.nix +++ b/modules/nixos/graphical/i3.nix @@ -128,6 +128,10 @@ in { "${modifier}+Shift+q" = '' exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; "${modifier}+Shift+x" = "exec ${lockCmd}"; + "${modifier}+Mod1+h" = + "exec --no-startup-id kitty sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} && ${pkgs.libnotify}/bin/notify-send --transient --expire-time 3000 \"Rebuilt home.\" || read'"; + "${modifier}+Mod1+r" = + "exec --no-startup-id kitty sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} && ${pkgs.libnotify}/bin/notify-send --transient --expire-time 3000 \"Rebuilt NixOS.\" || read'"; # Window options "${modifier}+q" = "kill"; From 4fefe5443590a9c8c0ad1151efb22142d9d49b50 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 2 Apr 2023 23:16:44 -0400 Subject: [PATCH 299/391] add email notifications not required to run aerc, uses imapnotify and notmuch/polybar closes #10 --- modules/common/mail/default.nix | 17 ++++++++--------- modules/nixos/graphical/polybar.nix | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/modules/common/mail/default.nix b/modules/common/mail/default.nix index 56c667b..27e3a16 100644 --- a/modules/common/mail/default.nix +++ b/modules/common/mail/default.nix @@ -27,10 +27,8 @@ home-manager.users.${config.user} = { programs.mbsync = { enable = true; }; - services.mbsync = lib.mkIf pkgs.stdenv.isLinux { - enable = true; - frequency = "*:0/5"; - }; + services.imapnotify.enable = pkgs.stdenv.isLinux && config.physical; + programs.notmuch.enable = true; accounts.email = { maildirBasePath = "${config.homePath}/mail"; accounts = { @@ -55,10 +53,11 @@ tls.enable = true; }; imapnotify = { - enable = false; - boxes = [ ]; - onNotify = ""; - onNotifyPost = ""; + enable = true; + boxes = [ "Inbox" ]; + onNotify = "${pkgs.isync}/bin/mbsync -a"; + onNotifyPost = + "${pkgs.libnotify}/bin/notify-send 'New mail arrived'"; }; maildir = { path = "main"; }; mbsync = { @@ -72,7 +71,7 @@ }; }; mu.enable = false; - notmuch.enable = false; + notmuch.enable = true; passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${ builtins.toString ../../../private/mailpass.age diff --git a/modules/nixos/graphical/polybar.nix b/modules/nixos/graphical/polybar.nix index 155f07e..61f1f0f 100644 --- a/modules/nixos/graphical/polybar.nix +++ b/modules/nixos/graphical/polybar.nix @@ -36,7 +36,7 @@ module-margin = 1; modules-left = "i3"; modules-center = "xwindow"; - modules-right = "pulseaudio date power"; + modules-right = "mailcount pulseaudio date power"; cursor-click = "pointer"; cursor-scroll = "ns-resize"; enable-ipc = true; @@ -101,6 +101,22 @@ # label-unmounted = "%mountpoint% not mounted"; # label-unmounted-foreground = colors.disabled; # }; + "module/mailcount" = { + type = "custom/script"; + interval = 10; + format = "