on master help sign in
Merge branch 'master' into fix-overflowing-spinner-2
commit9728ba3a1be733995893f7fd58952912894e346d authorRyan Trinkle <ryan.trinkle@gmail.com> dateSun 27 May 2018, 18:27 (8 years ago) parent04a81434ee8866
5 files changed+60−44
README.md+34−28 jobsets.nix+9−3 lib/command/src/Obelisk/Command/Thunk.hs+3−3 lib/selftest/src/Obelisk/SelfTest.hs+3 release.nix+11−10
README.md+34−28
@@ -10,40 +10,46 @@ Obelisk provides an easy way to develop and deploy your [Reflex](https://github.
1010 - [Android](#android)
1111
1212## Installing Obelisk
13−1. Install or update to nix 2.x
13+1. [Install Nix](https://nixos.org/nix/).
14+ If you already have Nix installed, make sure you have version 2.0 or higher. To check your current version, run `nix-env --version`.
14151. Set up nix caches
15− 1. Add this to `/etc/nixos/configuration.nix`:
16+ 1. If you are running NixOS, add this to `/etc/nixos/configuration.nix`:
1617 ```
17− nix.binaryCaches = [ "https://nixcache.reflex-frp.org" ];
18+ nix.binaryCaches = [ "https://cache.nixos.org/" "https://nixcache.reflex-frp.org" ];
1819 nix.binaryCachePublicKeys = [ "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=" ];
1920 ```
20−1. Install `ob`: `git clone git@github.com:obsidiansystems/obelisk && nix-env -f obelisk -iA command`.
21− Alternatively, if you prefer not to install to your user nix environment, you can
22− enter a shell with the `ob` command available: `nix-shell -A shell`.
23− After running `ob init` this becomes `nix-shell .obelisk/impl -A shell`
24− for subsequent shells (since `ob init` overwrites `default.nix`).
25−1. Get set up to access private repositories
26− 1. [Get set up to connect to GitHub with SSH](https://help.github.com/articles/connecting-to-github-with-ssh/)
27− 1. [Create a GitHub personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
28− 1. Set environment variables:
29− * NixOS: Add this to `/etc/nixos/configuration.nix`:
21+ 1. If you are using another operating system or linux distribution, ensure that these lines are present in `/etc/nix/nix.conf`:
3022 ```
31− nix.envVars = {
32− NIX_GITHUB_PRIVATE_USERNAME = "your-github-username";
33− NIX_GITHUB_PRIVATE_PASSWORD = "your-github-personal-access-token";
34− };
23+ sandbox = true
24+ substituters = https://cache.nixos.org https://nixcache.reflex-frp.org
25+ trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=
3526 ```
36− * MacOS:
37− ```
38− sudo launchctl setenv NIX_GITHUB_PRIVATE_USERNAME "your-github-username"
39− sudo launchctl setenv NIX_GITHUB_PRIVATE_PASSWORD "your-github-personal-access"
40− sudo launchctl stop org.nixos.nix-daemon
41− sudo launchctl start org.nixos.nix-daemon
42− ```
43− 1. `nix-env -i hub` OR `nix-env -iA nixos.gitAndTools.hub`
44− 1. `hub clone yourusername/yourproject`
45− * NOTE: you must authenticate with hub at least once, because the `ob` command uses `hub` for authentication
46− #TODO: Make ob do this itself (either invoke hub automatically or not depend on hub)
27+1. Install obelisk: `nix-env -f https://github.com/obsidiansystems/obelisk/archive/master.tar.gz -iA command`
28+
29+### Accessing private repositories
30+To allow the Nix builder to access private git repositories, follow these steps:
31+
32+1. [Get set up to connect to GitHub with SSH](https://help.github.com/articles/connecting-to-github-with-ssh/)
33+1. [Create a GitHub personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
34+1. Set environment variables:
35+ * NixOS: Add this to `/etc/nixos/configuration.nix`:
36+ ```
37+ nix.envVars = {
38+ NIX_GITHUB_PRIVATE_USERNAME = "your-github-username";
39+ NIX_GITHUB_PRIVATE_PASSWORD = "your-github-personal-access-token";
40+ };
41+ ```
42+ * MacOS:
43+ ```
44+ sudo launchctl setenv NIX_GITHUB_PRIVATE_USERNAME "your-github-username"
45+ sudo launchctl setenv NIX_GITHUB_PRIVATE_PASSWORD "your-github-personal-access"
46+ sudo launchctl stop org.nixos.nix-daemon
47+ sudo launchctl start org.nixos.nix-daemon
48+ ```
49+1. `nix-env -i hub` OR `nix-env -iA nixos.gitAndTools.hub`
50+1. `hub clone yourusername/yourproject`
51+ * NOTE: you must authenticate with hub at least once, because the `ob` command uses `hub` for authentication
52+ #TODO: Make ob do this itself (either invoke hub automatically or not depend on hub)
4753
4854## Developing an Obelisk project
4955
jobsets.nix+9−3
@@ -1,7 +1,8 @@
11{ prs }:
22
33let
4− pkgs = import ./nixpkgs {};
4+ self = import ./. {};
5+ pkgs = self.nixpkgs;
56 mkFetchGithub = value: {
67 inherit value;
78 type = "git";
@@ -45,7 +46,12 @@ let
4546 description = "#${num}: ${info.title}";
4647 inputs = {
4748 obelisk = {
48− value = "https://github.com/${info.head.repo.owner.login}/${info.head.repo.name}.git ${info.head.ref}";
49+ #NOTE: This should really use "pull/${num}/merge"; however, GitHub's
50+ #status checks only operate on PR heads. This creates a race
51+ #condition, which can currently only be solved by requiring PRs to be
52+ #up to date before they're merged. See
53+ #https://github.com/isaacs/github/issues/1002
54+ value = "https://github.com/obsidiansystems/obelisk pull/${num}/head";
4955 type = "git";
5056 emailresponsible = false;
5157 };
@@ -54,7 +60,7 @@ let
5460 };
5561 processedPrs = mapAttrs' makePr (builtins.fromJSON (builtins.readFile prs));
5662 jobsetsAttrs = processedPrs //
57− genAttrs ["develop"] branchJobset;
63+ genAttrs ["master"] branchJobset;
5864in {
5965 jobsets = pkgs.writeText "spec.json" (builtins.toJSON jobsetsAttrs);
6066}
lib/command/src/Obelisk/Command/Thunk.hs+3−3
@@ -497,9 +497,9 @@ getHubAuth
497497 -> IO (Maybe Auth)
498498getHubAuth domain = do
499499 hubConfig <- getXdgDirectory XdgConfig "hub"
500− Yaml.decodeFile hubConfig >>= \case
501− Nothing -> return Nothing
502− Just v -> return $ flip parseMaybe v $ \v' -> do
500+ Yaml.decodeFileEither hubConfig >>= \case
501+ Left _ -> return Nothing
502+ Right v -> return $ flip parseMaybe v $ \v' -> do
503503 Yaml.Array domainConfigs <- v' .: domain --TODO: Determine what multiple domainConfigs means
504504 [Yaml.Object domainConfig] <- return $ toList domainConfigs
505505 token <- domainConfig .: "oauth_token"
lib/selftest/src/Obelisk/SelfTest.hs+3
@@ -103,6 +103,9 @@ main = do
103103 it ("can enter " <> shell) $ inProj $ inShell "exit"
104104 it ("can build in " <> shell) $ inProj $ inShell $ "cabal new-build --" <> fromString compiler <> " all"
105105
106+ it "can build reflex project" $ inProj $ do
107+ run "nix-build" []
108+
106109 it "has idempotent thunk update" $ inProj $ do
107110 let update = run "ob" ["thunk", "update", thunk] >> commitAll
108111 u <- update
release.nix+11−10
@@ -6,17 +6,18 @@ with pkgs;
66
77{
88 inherit (self) command;
9+ built-skeleton = (import ./skeleton {}).all;
910 tests = {
1011 #TODO: Doesn't work; see discussion in https://www.pivotaltracker.com/story/show/157265140
11− ob-init = runCommand "ob-init" {
12− nativeBuildInputs = [
13− self.command
14− nix
15− ];
16− } ''
17− mkdir $out
18− cd $out
19− ob init --symlink=${self.path}
20− '';
12+ #ob-init = runCommand "ob-init" {
13+ # nativeBuildInputs = [
14+ # self.command
15+ # nix
16+ # ];
17+ #} ''
18+ # mkdir $out
19+ # cd $out
20+ # ob init --symlink=${self.path}
21+ #'';
2122 };
2223}