From 0d8595163fc72b255b35aab461fde13917504880 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Fri, 7 Jan 2022 15:25:29 +0100 Subject: [PATCH] add gitlab configuration and mail stuff --- nixos/configs/pepe/mail-fetcher.nix | 4 +- terranix/gitlab/.gitignore | 3 + terranix/gitlab/README.md | 7 ++ terranix/gitlab/config.nix | 31 +++++++ terranix/gitlab/flake.lock | 129 ++++++++++++++++++++++++++++ terranix/gitlab/flake.nix | 53 ++++++++++++ 6 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 terranix/gitlab/.gitignore create mode 100644 terranix/gitlab/README.md create mode 100644 terranix/gitlab/config.nix create mode 100644 terranix/gitlab/flake.lock create mode 100644 terranix/gitlab/flake.nix diff --git a/nixos/configs/pepe/mail-fetcher.nix b/nixos/configs/pepe/mail-fetcher.nix index 339972e..3391764 100644 --- a/nixos/configs/pepe/mail-fetcher.nix +++ b/nixos/configs/pepe/mail-fetcher.nix @@ -641,8 +641,8 @@ in ${pkgs.notmuch}/bin/notmuch new ${notmuchTaggingNew} ${threadTag "muted"} - ${threadTag "wohnung"} - ${threadTag "flagged"} + ${threadTag "mute"} + ${threadTag "ignore"} ''; }; systemd.timers.fetchmail = { diff --git a/terranix/gitlab/.gitignore b/terranix/gitlab/.gitignore new file mode 100644 index 0000000..e0e98f6 --- /dev/null +++ b/terranix/gitlab/.gitignore @@ -0,0 +1,3 @@ +.terraform* +terraform.tfstate* +config.tf.json diff --git a/terranix/gitlab/README.md b/terranix/gitlab/README.md new file mode 100644 index 0000000..f4dbbfc --- /dev/null +++ b/terranix/gitlab/README.md @@ -0,0 +1,7 @@ +# nix flake example + +This example shows how you could use terranix as flake. + +* `nix run` run `nix run ".#apply"` +* `nix run ".#apply"` run `terraform apply` +* `nix run ".#destroy"` run `terraform destroy` diff --git a/terranix/gitlab/config.nix b/terranix/gitlab/config.nix new file mode 100644 index 0000000..1e23633 --- /dev/null +++ b/terranix/gitlab/config.nix @@ -0,0 +1,31 @@ +# start with: +# export GITLAB_TOKEN="" +{ config, lib, ... }: +{ + terraform.required_providers.gitlab.source = "gitlabhq/gitlab"; + + provider.gitlab = { + base_url = "https://gitlab.ingolf-wagner.de/api/v4/"; + }; + + resource.gitlab_deploy_key = + let + ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDNRzdW7SYizwrECoTJbL0peeTkaRfAT5Jjefgad+MmHFHsRRy/q2bDQLlhKGPC4I0gXsaYuZSeSpaCwa6JHwDXDUjeSwj/osKE7lDnRx0XmGKKwZPNU4KuI9CUH450p5M9w3KgSmKEXJKayUz1/8E4WlSjfSkqpGwkhCeHtuIVd6Wei+fU/7uzYrL6tg8ZZD3omvvD4AxCEzNvM3wuX915K0x52GySJLpQUt9xYZLb1qrQAkVAnOE2ZZLx5rVzDLJkPrPRQ5Og3Yi3mT469AbKM/XPPuVgluiMCLOq8avAOQGK2brKjdaw2m3bDKuH18WJfMwwu/0uzSe1CWBwNj8/gAQapevhoYwMLjK9eJvWBh2Wc7tgHO51uZM3mVTylWFlsundM2ASssVHueReNpnUtMvXdCPHb0ZmZNy/3NW0u+y7FnLRvnrRSF8TYPeUYTOoRd0nbvwb6R0mBvHFqjs6ILLL7+d+JHCBnGAxu3AwgWAsS8LP3G+VL7arb1pEVJK52Svjoi2tPXWaRixAB1KxMep44UtY+TCGs+5fx++y2sUGhcEJBxXywpFmAPjOZLRuiDcnsWxZfTSMkQowoG6PUtcplasY4+NzJ/ivBjfka111KRLURNIRkCGaBZKPAROkGd9iKdiSENdpXRwubFl5ISjEPR3tdZaTY97w+hj8OQ=="; + work_repositories = { + mindcurv = "palo/mindcurv_nix"; + timewarrior = "palo/timewarrior_mindcurv"; + }; + + repository = name: project_path: { + name = name; + value = { + project = project_path; + title = "Deployment key"; + key = ssh_key; + }; + }; + + in + lib.mapAttrs' repository work_repositories; + +} diff --git a/terranix/gitlab/flake.lock b/terranix/gitlab/flake.lock new file mode 100644 index 0000000..37d94c7 --- /dev/null +++ b/terranix/gitlab/flake.lock @@ -0,0 +1,129 @@ +{ + "nodes": { + "bats-assert": { + "flake": false, + "locked": { + "lastModified": 1636059754, + "narHash": "sha256-ewME0l27ZqfmAwJO4h5biTALc9bDLv7Bl3ftBzBuZwk=", + "owner": "bats-core", + "repo": "bats-assert", + "rev": "34551b1d7f8c7b677c1a66fc0ac140d6223409e5", + "type": "github" + }, + "original": { + "owner": "bats-core", + "repo": "bats-assert", + "type": "github" + } + }, + "bats-support": { + "flake": false, + "locked": { + "lastModified": 1548869839, + "narHash": "sha256-Gr4ntadr42F2Ks8Pte2D4wNDbijhujuoJi4OPZnTAZU=", + "owner": "bats-core", + "repo": "bats-support", + "rev": "d140a65044b2d6810381935ae7f0c94c7023c8c3", + "type": "github" + }, + "original": { + "owner": "bats-core", + "repo": "bats-support", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1633074215, + "narHash": "sha256-epmR1H1amgFWuU7xW9OXGjsAqltMqCSqkv1U2+9rOlM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "378d2c5dcec7fef958cca3760448c09a9be2b7a3", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "terranix": "terranix" + } + }, + "terranix": { + "inputs": { + "bats-assert": "bats-assert", + "bats-support": "bats-support", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ], + "terranix-examples": "terranix-examples" + }, + "locked": { + "lastModified": 1636274003, + "narHash": "sha256-HDiyJGgyDUoLnpL8N+wDm3cM/vEfYYc/p4N1kKH/kLk=", + "owner": "terranix", + "repo": "terranix", + "rev": "87fe67a2c254e74c1c3f3206c504fe7ba76a3c59", + "type": "github" + }, + "original": { + "owner": "terranix", + "repo": "terranix", + "type": "github" + } + }, + "terranix-examples": { + "locked": { + "lastModified": 1633465925, + "narHash": "sha256-BfXRW1ZHpK5jh5CVcw7eFpGsWE1CyVxL8R+V7uXemaU=", + "owner": "terranix", + "repo": "terranix-examples", + "rev": "70bf5d5a1ad4eabef1e4e71c1eb101021decd5a4", + "type": "github" + }, + "original": { + "owner": "terranix", + "repo": "terranix-examples", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/terranix/gitlab/flake.nix b/terranix/gitlab/flake.nix new file mode 100644 index 0000000..0299b8c --- /dev/null +++ b/terranix/gitlab/flake.nix @@ -0,0 +1,53 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + terranix = { + url = "github:terranix/terranix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, flake-utils, terranix }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + terraform = pkgs.terraform_0_15; + terraformConfiguration = terranix.lib.terranixConfiguration { + inherit system; + modules = [ ./config.nix ]; + }; + in + { + defaultPackage = terraformConfiguration; + # nix develop + devShell = pkgs.mkShell { + buildInputs = [ + pkgs.terraform_0_15 + terranix.defaultPackage.${system} + ]; + }; + # nix run ".#apply" + apps.apply = { + type = "app"; + program = toString (pkgs.writers.writeBash "apply" '' + if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi + cp ${terraformConfiguration} config.tf.json \ + && ${terraform}/bin/terraform init \ + && ${terraform}/bin/terraform apply + ''); + }; + # nix run ".#destroy" + apps.destroy = { + type = "app"; + program = toString (pkgs.writers.writeBash "destroy" '' + if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi + cp ${terraformConfiguration} config.tf.json \ + && ${terraform}/bin/terraform init \ + && ${terraform}/bin/terraform destroy + ''); + }; + # nix run + defaultApp = self.apps.${system}.apply; + }); +}