Skip to content

Commit 3cd7c2b

Browse files
nix-shell support and fix shebangs (#656)
nix-shell support and fix shebangs Related to packit/private#46 Reviewed-by: Maja Massarini
2 parents e2ca452 + fdee585 commit 3cd7c2b

File tree

14 files changed

+223
-11
lines changed

14 files changed

+223
-11
lines changed

.envrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# shellcheck disable=all
2+
3+
export DIRENV_WARN_TIMEOUT=20s
4+
5+
eval "$(devenv direnvrc)"
6+
7+
# The use_devenv function supports passing flags to the devenv command
8+
# For example: use devenv --impure --option services.postgres.enable:bool true
9+
use devenv

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,16 @@ secrets/*/dev/*
1818

1919
# used in move_stable script
2020
move_stable_repositories
21+
22+
# Devenv
23+
.devenv*
24+
devenv.local.nix
25+
26+
# direnv
27+
.direnv
28+
29+
# Ansible collections from remote sources
30+
.ansible
31+
32+
# Python dependencies installed from devenv.sh
33+
.venv

devenv.lock

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1752456450,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "e2a9d0dd4cf87a1801c6d9e0d7a57bdd6de26ace",
10+
"type": "github"
11+
},
12+
"original": {
13+
"dir": "src/modules",
14+
"owner": "cachix",
15+
"repo": "devenv",
16+
"type": "github"
17+
}
18+
},
19+
"flake-compat": {
20+
"flake": false,
21+
"locked": {
22+
"lastModified": 1747046372,
23+
"owner": "edolstra",
24+
"repo": "flake-compat",
25+
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
26+
"type": "github"
27+
},
28+
"original": {
29+
"owner": "edolstra",
30+
"repo": "flake-compat",
31+
"type": "github"
32+
}
33+
},
34+
"git-hooks": {
35+
"inputs": {
36+
"flake-compat": "flake-compat",
37+
"gitignore": "gitignore",
38+
"nixpkgs": [
39+
"nixpkgs"
40+
]
41+
},
42+
"locked": {
43+
"lastModified": 1750779888,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
47+
"type": "github"
48+
},
49+
"original": {
50+
"owner": "cachix",
51+
"repo": "git-hooks.nix",
52+
"type": "github"
53+
}
54+
},
55+
"gitignore": {
56+
"inputs": {
57+
"nixpkgs": [
58+
"git-hooks",
59+
"nixpkgs"
60+
]
61+
},
62+
"locked": {
63+
"lastModified": 1709087332,
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"nixpkgs": {
76+
"locked": {
77+
"lastModified": 1751984180,
78+
"owner": "nixos",
79+
"repo": "nixpkgs",
80+
"rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0",
81+
"type": "github"
82+
},
83+
"original": {
84+
"owner": "nixos",
85+
"ref": "nixos-unstable",
86+
"repo": "nixpkgs",
87+
"type": "github"
88+
}
89+
},
90+
"root": {
91+
"inputs": {
92+
"devenv": "devenv",
93+
"git-hooks": "git-hooks",
94+
"nixpkgs": "nixpkgs",
95+
"pre-commit-hooks": [
96+
"git-hooks"
97+
]
98+
}
99+
}
100+
},
101+
"root": "root",
102+
"version": 7
103+
}

devenv.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ pkgs, lib, config, inputs, ... }:
2+
3+
{
4+
packages = [
5+
pkgs.openshift
6+
7+
pkgs.ansible
8+
pkgs.ansible-navigator
9+
];
10+
11+
languages.python = {
12+
enable = true;
13+
14+
venv = {
15+
enable = true;
16+
requirements = ''
17+
# Needed for k8s ansible module
18+
kubernetes
19+
20+
# Needed for changelog script
21+
click
22+
GitPython
23+
ogr
24+
25+
# Needed for move-stable script
26+
copr
27+
'';
28+
};
29+
};
30+
}

devenv.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
inputs:
2+
nixpkgs:
3+
# [TODO] Ideally swap to the cachix/rolling once Ansible issues are resolved.
4+
# url: github:cachix/devenv-nixpkgs/rolling
5+
url: github:nixos/nixpkgs/nixos-unstable

docs/deployment/continuous-deployment.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ It has several significant benefits:
3131
## Manual production re-deployment
3232

3333
1. Trigger `:prod` images builds
34-
3534
- Run [scripts/move_stable.py](https://github.com/packit/deployment/blob/main/scripts/move_stable.py) to move `stable` branches to a newer commit.
3635

3736
2. Import images -> re-deploy
38-
3937
- If you don't want to wait for [it to be done automatically](#continuous-deployment), you can
4038
[do that manually](#manually-import-a-newer-image) once the images are built (check Actions in each repo).
4139

docs/deployment/nix.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Nix & devenv support
3+
author: mfocko
4+
---
5+
6+
# Nix & devenv support
7+
8+
:::tip tl;dr
9+
10+
Ideal for atomic linux distributions and macOS setup.
11+
12+
There's one file (`devenv.nix`) containing everything that's needed to set up an
13+
environment for the project (`packit/deployment` in this case). All tools and
14+
deps are kept only for this project, i.e., they don't pollute the host system.
15+
16+
Since Nix and devenv.sh support pinning, it is also possible to acquire
17+
a reproducible environment.
18+
19+
[`direnv`](https://devenv.sh/automatic-shell-activation/) makes sure the development environment is set up upon entering the repo.
20+
21+
:::
22+
23+
## What is [Nix](https://nixos.org/)?
24+
25+
From the homepage:
26+
27+
> Nix is a tool that takes a unique approach to package management and system
28+
> configuration. Learn how to make reproducible, declarative and reliable systems.
29+
30+
Basically you have global environment and smaller `nix-shell`s that are usually
31+
tied to git repos (or any other directory). You aim for as small base environment
32+
as possible, i.e., you don't want to keep all utilities / dependencies everywhere.
33+
34+
One benefit, in comparison to containers, lies in the fact that the packages are
35+
defined by hash, name and version which allows them to be stored in a global
36+
location (usually `/nix`). Including packages in “environments” is done by
37+
adjusting `$PATH` (and related) variable.
38+
39+
## What is [devenv.sh](https://devenv.sh/)?
40+
41+
Builds on top of the _Nix_ and _nix-shell_ themselves. Is a bit more robust,
42+
cause it also allows specifying environment variables, defining tasks, services,
43+
and processes. For example it allows you to automatically spin up `nginx` or
44+
`postgres` server once you enter the repo.
45+
46+
## Getting started
47+
48+
Feel free to follow the [devenv.sh' “Getting Started”](https://devenv.sh/getting-started/).
49+
50+
1. You need to have _Nix_ set up. (single-user / non-daemon setup is recommended
51+
for users with SELinux enabled)
52+
2. Install the _devenv.sh_ itself.
53+
3. Have _direnv_ present (since it automatically loads the environment upon
54+
entering the directory with _devenv.sh_).
55+
56+
## Caveats
57+
58+
Bitwarden CLI is currently broken on macOS, therefore it's not included in the
59+
devenv.sh' config.

docs/deployment/resource-requirements.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,12 @@ resource requirements.
8383
1. Request adjustments of the quotas such that we can have some buffer (database
8484
migrations, higher load on service, etc.), but also could **permanently**
8585
scale up the workers if we find service to be more reliable that way
86-
8786
- Based on the calculations above, 2× the current quotas on memory would be
8887
sufficient, but if we were to scale the workers up too (and account for
8988
possible adjustments, e.g., Redict) we should probably go for 3×
9089

9190
1. Migrate tokman to different toolchain, it's a small self-contained app, so it
9291
is easy to migrate to either Rust or Go that should leave smaller footprint.
93-
9492
- Opened an issue for testing out running without Tokman deployment
9593
https://github.com/packit/tokman/issues/72
9694

docs/deployment/specifics/packit-service.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ To make it work, you need to:
6060
- Since our infrastructure does not support shared volumes, we need to attach
6161
one volume with a cache to each worker and one to each corresponding sandbox
6262
pod.
63-
6463
- In the case of workers, this is done during the deployment.
6564
- For sandboxes, there is an option in the service config (the environment
6665
variable needs to differ for each worker and is set during startup of the

docs/deployment/specifics/redict.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ We have tested a seamless migration from Redis to Redict on our production
88
deployment. To reproduce:
99

1010
1. We have deployed Redict to our production cluster.
11-
1211
- Defaults have been changed to:
1312

1413
```yaml
@@ -34,7 +33,6 @@ deployment. To reproduce:
3433

3534
3. After the data exchange is done, change **all** references in variables to
3635
redis to point to the new hostname, in this case `redis → redict`.
37-
3836
- Run
3937

4038
```

0 commit comments

Comments
 (0)