Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix flake updates #365

Merged
merged 8 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake -L
23 changes: 23 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Nix
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = mdfbaam.cachix.org-1:WCQinXaMJP7Ny4sMlKdisNUyhcO2MHnPoobUef5aTmQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://mdfbaam.cachix.org https://cache.nixos.org
- run: nix flake check
- run: nix build

6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# TPL and adamantine
include(SetupDealII)

project(adamantine LANGUAGES CXX VERSION 1.0.9)
project(Adamantine LANGUAGES CXX VERSION 1.0.9)

include(SetupTPLs)
include(SetupAdamantine)
Expand All @@ -36,14 +36,14 @@ if (ADAMANTINE_ENABLE_TESTS)
add_test(NAME indent_code
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ./indent
)
)
endif()

# Provide "indent" target for indenting all the header and the source files.
add_custom_target(indent
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ./indent
)
)

if (ADAMANTINE_ENABLE_DOCUMENTATION)
add_subdirectory(doc)
Expand Down
32 changes: 32 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": 6,
"configurePresets": [
{
"name": "generic-gcc-ninja",
"displayName": "Generic (gcc-ninja)",
"description": "Basic configuration with the GCC toolchain using Ninja generator.",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++"
}
}
],
"buildPresets": [
{
"name": "debug-gcc-ninja",
"displayName": "Debug (gcc-ninja)",
"description": "Compile a debug build using GCC.",
"configurePreset": "generic-gcc-ninja",
"configuration": "Debug"
},
{
"name": "release-gcc-ninja",
"displayName": "Release (gcc-ninja)",
"description": "Compile a release build using GCC.",
"configurePreset": "generic-gcc-ninja",
"configuration": "Release"
}
]
}

84 changes: 73 additions & 11 deletions NIX.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,81 @@
# Nix Install
## Nix

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

$ nix develop github:adamantine-sim/adamantine

to install the latest version on master. To install the lastest release use,
To get a shell with adamantine temporarily installed, run:

$ nix develop github:adamantine-sim/adamantine#release

To install from a working copy use,
$ nix shell github:adamantine-sim/adamantine
# Adamantine now available
$ adamantine --help

To install this permanently, run:

$ nix profile install github:adamantine-sim/adamantine

To get the latest stable release, use:

$ nix shell github:adamantine-sim/adamantine#adamantine.versions.stable

To build from a working copy use `nix develop` and run CMake manually:

$ nix develop

$ cmake -B build -GNinja
$ cmake --build build

## Cache

To avoid unnecessary builds, you can use the cache as configured in
`flake.nix`. The only requirement is that your user is a "trusted user" by the
nix dameon.

If you are not a trusted user, you may make yourself one by editing
`/etc/nix/nix.conf` and add the following line:

...
trusted-users = [YOUR USERNAME HERE]
...

Then, when running a nix operation with the Adamantine flake, you should be
prompted if you want to add the cache to your configuration. Say yes to all
queries to enable the cache permanently.

For more info, see the docs for this option [here][Trusted].

## direnv

This repository also supports `direnv` for integration with both your shell and
tools like VSCode.

First install direnv from either your distro or via Nix:

# Via apt...
$ sudo apt install direnv
# ... or nix.
$ nix profile install direnv

Setup direnv for your shell. Tutorials for various shells can be found
[here][DirenvHook]. For bash:

$ echo "eval \"\$(direnv hook bash)\"" >> ~/.bashrc

Restart your shell and then allow direnv:

$ cd path/to/my/adamantine
$ direnv allow

This will automatically enter the nix development shell whenever you enter the
adamantine directory.

If you use VSCode, a great extension that adds direnv support can be found
[here][DirenvVSCode].


[NIX]: https://nixos.org/download.html
[Flakes]: https://nixos.wiki/wiki/Flakes
[nix.dev]: https://nix.dev
[Determinate]: https://github.com/DeterminateSystems/nix-installer
[DirenvHook]: https://direnv.net/docs/hook.html
[DirenvVSCode]: https://marketplace.visualstudio.com/items?itemName=mkhl.direnv
[Trusted]: https://nix.dev/manual/nix/2.24/command-ref/conf-file#conf-trusted-users
2 changes: 2 additions & 0 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ endif()

file(COPY input.info DESTINATION ${CMAKE_BINARY_DIR}/bin)
file(COPY input_scan_path.txt DESTINATION ${CMAKE_BINARY_DIR}/bin)

install(TARGETS adamantine)
46 changes: 23 additions & 23 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading