123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- {
- config,
- lib,
- pkgs,
- ...
- }:
- let
- zscaler-cert = ''
- -----BEGIN CERTIFICATE-----
- MIIE0zCCA7ugAwIBAgIJANu+mC2Jt3uTMA0GCSqGSIb3DQEBCwUAMIGhMQswCQYD
- VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2Ux
- FTATBgNVBAoTDFpzY2FsZXIgSW5jLjEVMBMGA1UECxMMWnNjYWxlciBJbmMuMRgw
- FgYDVQQDEw9ac2NhbGVyIFJvb3QgQ0ExIjAgBgkqhkiG9w0BCQEWE3N1cHBvcnRA
- enNjYWxlci5jb20wHhcNMTQxMjE5MDAyNzU1WhcNNDIwNTA2MDAyNzU1WjCBoTEL
- MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBK
- b3NlMRUwEwYDVQQKEwxac2NhbGVyIEluYy4xFTATBgNVBAsTDFpzY2FsZXIgSW5j
- LjEYMBYGA1UEAxMPWnNjYWxlciBSb290IENBMSIwIAYJKoZIhvcNAQkBFhNzdXBw
- b3J0QHpzY2FsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
- qT7STSxZRTgEFFf6doHajSc1vk5jmzmM6BWuOo044EsaTc9eVEV/HjH/1DWzZtcr
- fTj+ni205apMTlKBW3UYR+lyLHQ9FoZiDXYXK8poKSV5+Tm0Vls/5Kb8mkhVVqv7
- LgYEmvEY7HPY+i1nEGZCa46ZXCOohJ0mBEtB9JVlpD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Q4E
- FgQUxbubUk2Kf9k68OUOSwrdgGuAtJYwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
- DQEBCwUAA4IBAQBNRKzWrQQBh1RAU023u0pgNjfk0OV5mTlb2024jCLmqG7U/eSC
- X8LoO/Gm3yVuj5RsoH8H5ftNU1j71c+dHg7+UVvQZRCOfgVIMnPCxuMvcaljRnLG
- qHaRCra5G3IOLrBtJDg9DgKg6/gUbg5DvZwiO5J21yzJWxy6wmoRBmy43DZBa2RV
- /rO3WOM0uuMp4DHqBIYx55d+4mdtshikZoys3TCiFH3C11xrUwkIdNEqvMcjl/Pr
- 5WrzfbTpDzvo/GCkPhA0thVgUBx4LXB8HizVmDZgGbSuh7ic7LHyh1ahE0fqGX9C
- ZvHif3XTcAZlNkilVHvF3pM4EIosFEc6dHFy
- -----END CERTIFICATE-----
- '';
- aws-cert =
- (builtins.readFile "${pkgs.awscli2}/lib/python${pkgs.awscli2.python.pythonVersion}/site-packages/awscli/botocore/cacert.pem")
- + zscaler-cert;
- full-cert =
- (builtins.readFile /etc/ssl/cert.pem) + aws-cert + internal-cert + internal-staging-cert;
- zscaler-cert-file = pkgs.writeText "zscaler-cert.pem" zscaler-cert;
- aws-cert-file = pkgs.writeText "aws-cert.pem" aws-cert;
- full-cert-file = pkgs.writeText "full-cert.pem" full-cert;
- zscaler-jdk = pkgs.jdk.overrideAttrs (old: {
- # passthru.home must be set to ensure JAVA_HOME is set correctly
- # See https://github.com/nix-community/home-manager/blob/086f619dd991a4d355c07837448244029fc2d9ab/modules/programs/java.nix#L39-L41
- # and https://github.com/NixOS/nixpkgs/blob/4877ea239f4d02410c3516101faf35a81af0c30e/pkgs/development/compilers/openjdk/jre.nix#L32
- passthru.home = "${zscaler-jdk}"; # make sure JAVA_HOME is set
- installPhase =
- # This is probably equivalent to
- # $out/bin/keytool -import -noprompt -trustcacerts -alias zscalerrootca -keystore $out/lib/security/cacerts <<< "${zscaler-cert}"
- # but follow the zscaler instructions just in case
- old.installPhase
- + ''
- ${pkgs.openssl}/bin/openssl x509 -inform pem -outform der <<< "${zscaler-cert}" | $out/bin/keytool -import -noprompt -trustcacerts -alias zscalerrootca -keystore $out/lib/security/cacerts
- '';
- });
- zscaler-lein = pkgs.leiningen.override { jdk = zscaler-jdk; };
- zscaler-clojure = pkgs.clojure.override { jdk = zscaler-jdk; };
- toggle = pkgs.writeShellScriptBin "remote-toggle" ''
- ssh -nT pi "playerctl play-pause" 2>/dev/null
- '';
- in
- {
- imports = [ ./includes/darwin.nix ];
- # Let Home Manager install and manage itself.
- programs.home-manager.enable = true;
- # Home Manager needs a bit of information about you and the
- # paths it should manage.
- home.username = "dmorgan";
- home.homeDirectory = "/Users/dmorgan";
- home.sessionPath = [ "$HOME/.costar/auth2aws" ];
- home.sessionVariables = {
- AWS_DEFAULT_REGION = "eu-west-1";
- AWS_PROFILE = "aws_otm_dev_developers";
- AM_PROFILE = "staging";
- AWS_CA_BUNDLE = "${aws-cert-file}";
- CURL_CA_BUNDLE = "${full-cert-file}";
- NIX_SSL_CERT_FILE = "${full-cert-file}";
- NODE_EXTRA_CA_CERTS = "${zscaler-cert-file}";
- JVM_OPTS = "-Dcom.amazonaws.sdk.disableCertChecking";
- LEIN_JVM_OPTS = "-Dcom.amazonaws.sdk.disableCertChecking";
- };
- home.shellAliases = {
- notify_success = ''( osascript -e 'display notification "The command finished" with title "Success"' && afplay /System/Library/Sounds/Ping.aiff && say done )'';
- notify_failure = ''( osascript -e 'display notification "The command failed" with title "Failure"' && afplay /System/Library/Sounds/Sosumi.aiff && say failed )'';
- notify = "notify_success || notify_failure";
- auth = "auth2aws login -r aws_otm_dev_developers,aws_otm_prd_developers && osascript -e 'tell app \"iTerm\" to activate'";
- yarn_build = "aws codeartifact login --tool npm --repository otm-js --domain otm --domain-owner 103567893073 --region eu-west-1 --profile aws_otm_dev_developers && yarn && yarn build && notify";
- };
- home.packages = with pkgs; [
- zscaler-clojure
- zscaler-lein
- toggle
- ];
- home.file = {
- "certs/zscaler-cert.pem".source = zscaler-cert-file;
- "certs/aws-cert.pem".source = aws-cert-file;
- "certs/full-cert.pem".source = full-cert-file;
- "certs/internal-ca.pem".text = internal-cert;
- "certs/staging-internal-ca.pem".text = internal-staging-cert;
- ".skhdrc".text = "play : remote-toggle";
- };
- sops.secrets = {
- "git_email_config/otm" = { };
- "ssh_config/otm" = { };
- };
- programs.java = {
- enable = true;
- package = zscaler-jdk;
- };
- programs.git = {
- signing.signByDefault = lib.mkForce false;
- includes = lib.mkForce [
- { path = config.sops.secrets."git_email_config/otm".path; }
- {
- path = config.sops.secrets."git_email_config/default".path;
- condition = "gitdir:~/src/personal/";
- }
- {
- path = config.sops.secrets."git_email_config/default".path;
- condition = "gitdir:~/dotfiles/";
- }
- {
- contents = {
- commit.gpgSign = true;
- tag.gpgSign = true;
- };
- condition = "gitdir:~/src/personal/";
- }
- {
- contents = {
- commit.gpgSign = true;
- tag.gpgSign = true;
- };
- condition = "gitdir:~/dotfiles/";
- }
- ];
- extraConfig = {
- github.user = "david-morgan-otm";
- http.sslcainfo = "${full-cert-file}";
- };
- ignores = [
- ".envrc"
- ".clj-kondo"
- "shell.nix"
- ".direnv"
- ".dir-locals.el"
- "browser-tests/package-lock.json"
- "resources/react-app/package-lock.json"
- "resources/next/package-lock.json"
- ];
- };
- programs.ssh = {
- includes = [ config.sops.secrets."ssh_config/otm".path ];
- matchBlocks = {
- "github.com" = lib.mkForce {
- hostname = "github.com";
- user = "git";
- identityFile = "~/.ssh/id_rsa";
- identitiesOnly = true;
- };
- "github.com-personal" = {
- hostname = "github.com";
- user = "git";
- identityFile = "~/.ssh/id_ed25519";
- identitiesOnly = true;
- };
- };
- };
- # This value determines the Home Manager release that your
- # configuration is compatible with. This helps avoid breakage
- # when a new Home Manager release introduces backwards
- # incompatible changes.
- #
- # You can update Home Manager without changing this value. See
- # the Home Manager release notes for a list of state version
- # changes in each release.
- home.stateVersion = "21.11";
- }
|