Skip to content

Commit 087317a

Browse files
authored
Merge pull request #365 from cadkin/nix-flake
Nix flake updates
2 parents 5cab591 + 789fffa commit 087317a

File tree

18 files changed

+535
-298
lines changed

18 files changed

+535
-298
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake -L

.github/workflows/nix.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Nix
3+
on: [push, pull_request]
4+
jobs:
5+
test:
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest, macos-latest]
9+
runs-on: ${{ matrix.os }}
10+
defaults:
11+
run:
12+
working-directory: ./
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: cachix/install-nix-action@v27
16+
with:
17+
nix_path: nixpkgs=channel:nixos-unstable
18+
extra_nix_config: |
19+
trusted-public-keys = mdfbaam.cachix.org-1:WCQinXaMJP7Ny4sMlKdisNUyhcO2MHnPoobUef5aTmQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
20+
substituters = https://mdfbaam.cachix.org https://cache.nixos.org
21+
- run: nix flake check
22+
- run: nix build
23+

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
1414
# TPL and adamantine
1515
include(SetupDealII)
1616

17-
project(adamantine LANGUAGES CXX VERSION 1.0.9)
17+
project(Adamantine LANGUAGES CXX VERSION 1.0.9)
1818

1919
include(SetupTPLs)
2020
include(SetupAdamantine)
@@ -36,14 +36,14 @@ if (ADAMANTINE_ENABLE_TESTS)
3636
add_test(NAME indent_code
3737
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
3838
COMMAND ./indent
39-
)
39+
)
4040
endif()
4141

4242
# Provide "indent" target for indenting all the header and the source files.
4343
add_custom_target(indent
4444
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
4545
COMMAND ./indent
46-
)
46+
)
4747

4848
if (ADAMANTINE_ENABLE_DOCUMENTATION)
4949
add_subdirectory(doc)

CMakePresets.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "generic-gcc-ninja",
6+
"displayName": "Generic (gcc-ninja)",
7+
"description": "Basic configuration with the GCC toolchain using Ninja generator.",
8+
"generator": "Ninja Multi-Config",
9+
"binaryDir": "${sourceDir}/build/${presetName}",
10+
"cacheVariables": {
11+
"CMAKE_CXX_COMPILER": "g++"
12+
}
13+
}
14+
],
15+
"buildPresets": [
16+
{
17+
"name": "debug-gcc-ninja",
18+
"displayName": "Debug (gcc-ninja)",
19+
"description": "Compile a debug build using GCC.",
20+
"configurePreset": "generic-gcc-ninja",
21+
"configuration": "Debug"
22+
},
23+
{
24+
"name": "release-gcc-ninja",
25+
"displayName": "Release (gcc-ninja)",
26+
"description": "Compile a release build using GCC.",
27+
"configurePreset": "generic-gcc-ninja",
28+
"configuration": "Release"
29+
}
30+
]
31+
}
32+

NIX.md

+73-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,81 @@
1-
# Nix Install
1+
## Nix
22

3-
First install the [Nix package manager][NIX] and then enable
4-
[Flakes]. See [nix.dev][nix.dev] for more help with Nix. To install
5-
without cloning from this repository use,
3+
First install the [Nix package manager][NIX] and then enable [Flakes][Flakes].
4+
Alternatively, check out the [Determinate Systems Installer][Determinate] for
5+
an out of the box experience. See [nix.dev][nix.dev] for more help with Nix.
66

7-
$ nix develop github:adamantine-sim/adamantine
8-
9-
to install the latest version on master. To install the lastest release use,
7+
To get a shell with adamantine temporarily installed, run:
108

11-
$ nix develop github:adamantine-sim/adamantine#release
12-
13-
To install from a working copy use,
9+
$ nix shell github:adamantine-sim/adamantine
10+
# Adamantine now available
11+
$ adamantine --help
12+
13+
To install this permanently, run:
14+
15+
$ nix profile install github:adamantine-sim/adamantine
16+
17+
To get the latest stable release, use:
18+
19+
$ nix shell github:adamantine-sim/adamantine#adamantine.versions.stable
20+
21+
To build from a working copy use `nix develop` and run CMake manually:
1422

1523
$ nix develop
16-
24+
$ cmake -B build -GNinja
25+
$ cmake --build build
26+
27+
## Cache
28+
29+
To avoid unnecessary builds, you can use the cache as configured in
30+
`flake.nix`. The only requirement is that your user is a "trusted user" by the
31+
nix dameon.
32+
33+
If you are not a trusted user, you may make yourself one by editing
34+
`/etc/nix/nix.conf` and add the following line:
35+
36+
...
37+
trusted-users = [YOUR USERNAME HERE]
38+
...
39+
40+
Then, when running a nix operation with the Adamantine flake, you should be
41+
prompted if you want to add the cache to your configuration. Say yes to all
42+
queries to enable the cache permanently.
43+
44+
For more info, see the docs for this option [here][Trusted].
45+
46+
## direnv
47+
48+
This repository also supports `direnv` for integration with both your shell and
49+
tools like VSCode.
50+
51+
First install direnv from either your distro or via Nix:
52+
53+
# Via apt...
54+
$ sudo apt install direnv
55+
# ... or nix.
56+
$ nix profile install direnv
57+
58+
Setup direnv for your shell. Tutorials for various shells can be found
59+
[here][DirenvHook]. For bash:
60+
61+
$ echo "eval \"\$(direnv hook bash)\"" >> ~/.bashrc
62+
63+
Restart your shell and then allow direnv:
64+
65+
$ cd path/to/my/adamantine
66+
$ direnv allow
67+
68+
This will automatically enter the nix development shell whenever you enter the
69+
adamantine directory.
70+
71+
If you use VSCode, a great extension that adds direnv support can be found
72+
[here][DirenvVSCode].
73+
74+
1775
[NIX]: https://nixos.org/download.html
1876
[Flakes]: https://nixos.wiki/wiki/Flakes
1977
[nix.dev]: https://nix.dev
78+
[Determinate]: https://github.com/DeterminateSystems/nix-installer
79+
[DirenvHook]: https://direnv.net/docs/hook.html
80+
[DirenvVSCode]: https://marketplace.visualstudio.com/items?itemName=mkhl.direnv
81+
[Trusted]: https://nix.dev/manual/nix/2.24/command-ref/conf-file#conf-trusted-users

application/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ endif()
2121

2222
file(COPY input.info DESTINATION ${CMAKE_BINARY_DIR}/bin)
2323
file(COPY input_scan_path.txt DESTINATION ${CMAKE_BINARY_DIR}/bin)
24+
25+
install(TARGETS adamantine)

flake.lock

+23-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)