2 supportedSystems ? [ builtins.currentSystem ]
5 nginxRoot = "/run/nginx";
6 obelisk = import ./default.nix {};
7 # Get NixOS a pre-release 20.03 that contains the python based tests and recursive nix
8 pkgs = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/archive/3de5266.tar.gz) {};
9 sshKeys = import (pkgs.path + /nixos/tests/ssh-keys.nix) pkgs;
10 make-test = import (pkgs.path + /nixos/tests/make-test-python.nix);
11 obelisk-everywhere = (import ./all-builds.nix { inherit supportedSystems; }).x86_64-linux.cache;
12 snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
13 snakeOilPublicKey = sshKeys.snakeOilPublicKey;
19 networking.firewall.allowedTCPPorts = [ 22 80 ];
23 environment.systemPackages = [
26 users.users.root.openssh.authorizedKeys.keys = [
33 (pkgs.path + /nixos/modules/installer/cd-dvd/channel.nix)
35 nix.useSandbox = false;
36 nix.binaryCaches = [];
37 environment.systemPackages = [
48 privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}'';
49 thunkableSample = pkgs.writeText "default.nix" ''
50 let pkgs = import <nixpkgs> {}; in pkgs.git
52 invalidThunkableSample = pkgs.writeText "default.nix" ''
53 let pkgs = import <nixpkgs> {}; in pkgtypo.git
55 sshConfigFile = pkgs.writeText "ssh_config" ''
57 StrictHostKeyChecking no
58 UserKnownHostsFile=/dev/null
61 IdentityFile=~/.ssh/id_rsa
67 with subtest("obelisk is installed and git is configured"):
68 client.succeed("ob --help")
69 client.succeed('git config --global user.email "you@example.com"')
70 client.succeed('git config --global user.name "Your Name"')
72 githost.wait_for_open_port("22")
74 with subtest("the client can access the server via ssh"):
75 client.succeed("mkdir -p ~/.ssh/")
77 "cp ${privateKeyFile} ~/.ssh/id_rsa"
79 client.succeed("chmod 600 ~/.ssh/id_rsa")
80 client.wait_until_succeeds(
81 "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa githost true"
84 "cp ${sshConfigFile} ~/.ssh/config"
86 client.wait_until_succeeds("ssh githost true")
88 with subtest("a remote bare repo can be started"):
89 githost.succeed("mkdir -p ~/myorg/myapp.git")
90 githost.succeed("cd ~/myorg/myapp.git && git init --bare")
92 with subtest("a git project can be configured with a remote using ssh"):
93 client.succeed("mkdir -p ~/code/myapp")
94 client.succeed("cd ~/code/myapp && git init")
96 "cp ${thunkableSample} ~/code/myapp/default.nix"
98 client.succeed("cd ~/code/myapp && git add .")
100 client.succeed('cd ~/code/myapp && git commit -m "Initial"')
102 "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
106 with subtest("pushing code to the remote"):
107 client.succeed("cd ~/code/myapp && git push -u origin master")
108 client.succeed("cd ~/code/myapp && git status")
110 with subtest("obelisk can pack"):
111 client.succeed("ob -v thunk pack ~/code/myapp")
112 client.succeed("grep -qF 'git.json' ~/code/myapp/thunk.nix")
113 client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
114 client.succeed("ob -v thunk unpack ~/code/myapp")
116 with subtest("obelisk can set the public / private flag"):
117 client.succeed("ob -v thunk pack ~/code/myapp --private")
118 client.fail("""grep -qF '"private": practice' ~/code/myapp/git.json""")
119 client.succeed("""grep -qF '"private": true' ~/code/myapp/git.json""")
120 client.succeed("nix-build ~/code/myapp")
121 client.succeed("ob -v thunk unpack ~/code/myapp")
122 client.succeed("ob -v thunk pack ~/code/myapp --public")
123 client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""")
124 client.succeed("nix-build ~/code/myapp")
125 client.succeed("ob -v thunk unpack ~/code/myapp")
127 with subtest("building an invalid thunk fails"):
128 client.succeed("cd ~/code/myapp && git checkout -b bad")
130 "cp ${invalidThunkableSample} ~/code/myapp/default.nix"
132 client.succeed("cd ~/code/myapp && git add .")
133 client.succeed('cd ~/code/myapp && git commit -m "Bad commit"')
134 client.succeed("cd ~/code/myapp && git push -u origin bad")
135 client.succeed("ob -v thunk pack ~/code/myapp --public")
136 client.fail("nix-build ~/code/myapp")
137 client.succeed("ob -v thunk unpack ~/code/myapp")
138 client.succeed("cd ~/code/myapp && git checkout master")
140 with subtest("obelisk can detect private repos"):
141 client.succeed("ob -v thunk pack ~/code/myapp")
142 client.succeed("""grep -qF '"private": true' ~/code/myapp/git.json""")
143 client.succeed("ob -v thunk unpack ~/code/myapp")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list