ALPHA: wire is a tool to deploy nixos systems
wire.althaea.zone/
1---
2comment: true
3title: Preparing Repo & Shell
4description: Adding npins sources and a nix development shell.
5---
6
7# {{ $frontmatter.title }}
8
9{{ $frontmatter.description }}
10
11## Initialising with Git & `npins`
12
13First, lets create an adhoc shell to bring these two tools into our $PATH.
14
15```sh
16$ nix-shell -p git npins
17[nix-shell]$ git --version
18git version 2.51.0
19[nix-shell]$ npins --version
20npins 0.3.1
21```
22
23Great! Now lets use Git & `npins` to create a new Git repo and initialise it.
24`npins init` may take a while to download `nixpkgs`.
25
26```sh
27[nix-shell]$ git init wire-tutorial
28Initialized empty Git repository in /home/.../wire-tutorial/.git/
29[nix-shell]$ cd wire-tutorial/
30[nix-shell]$ npins init
31[INFO ] Welcome to npins!
32[INFO ] Creating `npins` directory
33[INFO ] Writing default.nix
34[INFO ] Writing initial lock file (empty)
35[INFO ] Successfully written initial files to 'npins/sources.json'.
36```
37
38This has created a pinned version of `nixpkgs` for us to use in our wire hive.
39
40## Adding wire as a dependency
41
42We can now need to tell `npins` to use `mrshmllow/wire` as a dependency.
43
44```sh
45[nix-shell]$ npins add github mrshmllow wire --branch stable
46[INFO ] Adding 'wire' …
47 repository: https://github.com/mrshmllow/wire.git
48 pre_releases: false
49 submodules: false
50 version: v0.4.0
51 revision: f33d80c15b17c85d557d533441609a59a2210941
52 hash: 0wgah341hvjpvppkgwjrj50rvzf56ccmjz720xsl3mw38h9nn6sr
53 frozen: false
54```
55
56Great, now lets confirm the two dependencies we have added to this `npins`
57project:
58
59```sh
60[nix-shell]$ npins show
61nixpkgs: (git repository)
62 repository: https://github.com/pkpbynum/nixpkgs.git
63 branch: pb/disk-size-bootloader
64 submodules: false
65 revision: da2060bdc1c9bc35acc4eafa265ba6b6c64f9926
66 url: https://github.com/pkpbynum/nixpkgs/archive/da2060bdc1c9bc35acc4eafa265ba6b6c64f9926.tar.gz
67 hash: 0j07gvnm7c5mzw1313asa8limzbmsbnsd02dcw22ing8fg3vbb7g
68 frozen: false
69
70wire: (git release tag)
71 repository: https://github.com/mrshmllow/wire.git
72 pre_releases: false
73 submodules: false
74 version: v0.4.0
75 revision: f33d80c15b17c85d557d533441609a59a2210941
76 hash: 0wgah341hvjpvppkgwjrj50rvzf56ccmjz720xsl3mw38h9nn6sr
77 frozen: false
78```
79
80## Creating a `shell.nix`
81
82Open a text editor to edit `shell.nix` in the `wire-tutorial` directory.
83
84```nix:line-numbers [shell.nix]
85let
86 sources = import ./npins;
87 pkgs = import sources.nixpkgs { };
88 wire = import sources.wire;
89in
90pkgs.mkShell {
91 packages = [
92 wire.packages.x86_64-linux.wire-small
93 pkgs.npins
94 pkgs.git
95 ];
96
97 shellHook = ''
98 export NIX_PATH="nixpkgs=${sources.nixpkgs.outPath}"
99 '';
100}
101```
102
103You should now `exit` to quit the old shell, and
104enter a new shell with `nix-shell`. Since we added wire as a package, our new
105shell should have wire in the $PATH:
106
107```sh
108[nix-shell]$ exit
109exit
110$ cd wire-tutorial/
111$ nix-shell
112[nix-shell]$ wire --version
113wire 0.5.0
114Debug: Hive::SCHEMA_VERSION 0
115
116```