{"id":26005392,"url":"https://github.com/precice/nix-packages","last_synced_at":"2025-03-05T20:53:53.193Z","repository":{"id":176401695,"uuid":"648195871","full_name":"precice/nix-packages","owner":"precice","description":"Official preCICE adapters and solvers packaged with the Nix package manager. See https://precice.discourse.group/t/precice-goes-nix-os-improving-reproducibility-of-scientific-software/","archived":false,"fork":false,"pushed_at":"2024-11-28T08:19:39.000Z","size":1005,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-28T09:26:02.429Z","etag":null,"topics":["nix","precice","simulation"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/precice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://precice.org/community-support-precice"}},"created_at":"2023-06-01T12:21:07.000Z","updated_at":"2024-11-28T08:19:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"57f8e58a-aad0-4005-91ca-6f63a6058fd6","html_url":"https://github.com/precice/nix-packages","commit_stats":null,"previous_names":["precice/nix-packages"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Fnix-packages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Fnix-packages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Fnix-packages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Fnix-packages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/precice","download_url":"https://codeload.github.com/precice/nix-packages/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242103941,"owners_count":20072368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nix","precice","simulation"],"created_at":"2025-03-05T20:53:52.563Z","updated_at":"2025-03-05T20:53:53.175Z","avatar_url":"https://github.com/precice.png","language":"Nix","funding_links":["https://precice.org/community-support-precice"],"categories":[],"sub_categories":[],"readme":"# preCICE VM, solvers and adapters, built with Nix/NixOS\n\nThis repository is the result of a research project about reproducibility in scientific software with a case study on preCICE using the [Nix package manager](https://nixos.org/).\nThe value of this repo are the Nix package definitions of precice-adapters, several solvers and the preCICE distribution VM.\nThose outputs can be built reproducibly using Nix.\n\n\u003c!-- The paper can be found here TODO add link to paper once it's published --\u003e\n\n## Structure of the repo\n\n```\n.\n├── clean.sh                             # Script to undo execution of ./setup.sh\n├── configuration-light.nix              #\n├── configuration.nix                    # The definition of the preCICE VM\n├── flake.lock                           # All dependencies pinned for Nix\n├── flake.nix                            # Definitions of all inputs and outputs\n├── precice-packages                     # Package definitions\n│   ├── dune                             # Each package has its own directory\n│   │   ├── 0001-no-upgrade.patch        # Some packages contain patch files so the package builds with Nix\n│   │   ├── 0002-no-dune-configure.patch #\n│   │   └── default.nix                  # default.nix is the file that contains the package definition\n│   ├── ...                              # This goes on for each solver/adapter\n│   └── default.nix                      # The precice-packages/default.nix represents a Nix overlay\n├── precice-vm.qcow2                     # [not in git] This file us used to store all state of the VM and is created the first time the VM runs\n├── README.md                            # This file\n├── result                               # [not in git] Autogenerated symlink that points to the latest Nix build\n├── setup.sh                             # File to setup and install Nix in a user context (no root required)\n├── timings.md                           #\n├── vagrant.pub                          # Vagrant public key\n└── vscode.nix                           # Visual Studio Code for the VM\n```\n\n## Getting Started\n\nTo build the preCICE VM, the Nix binary is required.\nWe provide a [setup script](./setup.sh) to get the Nix package manager if it is not already available.\nAfter that, you can use Nix to build preCICE packages, the preCICE VM image, either as a bootable iso file, a qemu start script or a Vagrant VirtualBox VM image.\n\nThe first time you issue a Nix command inside the projects directory you are asked if you want to use the garnix cache.\nTo avoid building everything from scratch for yourself, you should definitely answer the prompt with yes here.\nWhen enabled, Nix uses the garnix cache which contains all packages and images the flake contains as outputs.\nThose outputs are built inside a CI job, so on every commit.\n\nUsing garnix only works if you use the `./setup.sh` script or the preCICE VM we provide, you shouldn't have to configure anything.\nIf you use a vanilla solution, please refer to [the section below](#notes-regarding-vanilla-nixnixos), but if there are any \"out of the box\" problems with the setup script or the VM, please open an issue.\n\n```\n# 0. If nix is not already available, we first need to download it\n# The easiest way is to use the ./setup.sh script provided by the repo, otherwise please see https://nixos.org/download\nbash ./setup.sh\n# After the script succeeded the `nix-static` command should be available\n# If installed via the official installer, the command `nix` should be available\n# 1. in any directory you can now run the following command to install calculix adapter and openfoam with the respected adapter\nnix shell --accept-flake-config github:precice/nix-packages#precice-calculix-adapter github:precice/nix-packages#precice-openfoam-adapter\n# 2. inside this repository you can now run the following command to build a qemu VM image\nnix build '.#vm'\n# You can replace `vm` with\n# - vm-light                 -- to build a lightweight qemu VM imsage\n# - vagrant-vbox-image       -- to build a vagrant virtual box image\n# - vagrant-vbox-image-light -- to build a vagrant virtual box image of the lightweight configuration\n# - iso                      -- to build a bootable iso\n# - iso-light                -- to build a bootable iso of the lightweight configuration\n```\n\n### Notes regarding vanilla Nix/NixOS\n\n#### experimental-features\n\nIf you use vanilla Nix/NixOS, you need to enable experimental features, which can be enabled like so:\n\n```plaintext\nmkdir -p ~/.config/nix \u0026\u0026 echo 'experimental-features = nix-command flakes' \u003e\u003e ~/.config/nix/nix.conf\n```\n\nFor NixOS, you can also [set this option declaratively](https://github.com/precice/nix-packages/commit/4bc81bb0cd6f889ef4a08328bc79bddde98777fe#diff-7fb0d30826718de8f216d0f0a15452c87445e0bbb745754bf77e1320079f46f9R11).\n\n#### Trusting the garnix cache\n\nWhen you install NixOS or if you install Nix in multi-user mode, you additionally need to configure support for the garnix cache.\nA single user installation (i.e. you run the `nix` binary directly without talking to the Nix daemon) should not be affected by this.\n\nFor security reasons, only https://cache.nixos.org is allowed as a binary cache by default and only the root user can use other binary caches.\nThere are several ways to solve this problem, you should choose only one (they are ordered by highest preference first).\n\nFor Nix in multi-user mode:\n1. Add `substituters = https://cache.garnix.io` and `trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=` to your `nix.conf` file and restart the daemon\n2. Add `trusted-users = @wheel` to your `nix.conf` file and restart the daemon\n3. Run the command, `nix shell` for instance, as the root user using `sudo nix shell`\n\nFor NixOS:\n1. Add [these two lines](https://github.com/precice/nix-packages/commit/4bc81bb0cd6f889ef4a08328bc79bddde98777fe#diff-7fb0d30826718de8f216d0f0a15452c87445e0bbb745754bf77e1320079f46f9R12-R13) to your `/etc/nixos/configuration.nix` and run `sudo nixos-rebuild switch`\n2. Add your user or the wheel group to the [`trusted-users` setting](https://search.nixos.org/options?channel=23.05\u0026show=nix.settings.trusted-users\u0026from=0\u0026size=50\u0026sort=relevance\u0026type=packages\u0026query=nix.settings.trusted-users) by adding `nix.settings.trusted-users = [ \"@wheel\" ];` to your `/etc/nixos/configuration.nix` and running `sudo nixos-rebuild switch`\n3. Run the command, `nix shell` for instance, as the root user using `sudo nix shell`\n\n## Running the perpendicular-flap\n\nHaving Nix installed, you don't need to build the whole VM locally.\nTo run the perpendicular-flap tutorial, clone [the tutorials repository](https://github.com/precice/tutorials/), open two terminals and `cd` into the respective directories `perpendicular-flap/fluid-openfoam` and `perpendicular-flap/solid-calculix`.\nIn each of the shells run `nix shell github:precice/nix-packages#precice-calculix-adapter github:precice/nix-packages#precice-openfoam-adapter`.\nThe first time you run this, Nix will ask you, if you want to use the garnix cache, to which you should reply with `y` (otherwise OpenFOAM and CalculiX will be built locally).\nInside the solid-calculix directory, you can run `./run.sh` directly while in the fluid-openfoam directory, you have to issue the command `source \"$(nix eval --raw 'github:precice/nix-packages#precice-openfoam-adapter.out')/bin/set-openfoam-adapter-vars\"` before running the `./run.sh` script.\n\nThe simulation should run with both participants now.\n\n## VirtualBox Vagrant image\n\nTo build and use the Vagrant image:\n1. `nix build '.#vagrant-vbox-image'`, this will build the .box file and create a symlink `result` in the current directory\n2. `vagrant box add ./result --name preCICE` to add the box\n3. As usual, run `vagrant up`\n\nTo apply changes in the configuration.nix to the VM, you can run `sudo nixos-rebuild --flake /vagrant# switch` from within the VM.\n\n## HPC Environment\n\nThis section is only relevant for the Simtech HPC of the University of Stuttgart.\nIt assumes a Linux installation.\n\nIn order to use the cluster, you have to apply, connect to the VPN, connect to a node via ssh and setup Nix.\n\n1. Apply for the cluster\n\nThis won't be documented here.\n\n2. Connect to the VPN:\n\nInstall `openconnect` and issue `sudo openconnect --user=st123456@stud.uni-stuttgart.de vpn.tik.uni-stuttgart.de`.\nIf `gopass` or another password store is installed, you can also let openconnect read the password from stdin: `gopass uni/st | sudo openconnect --user=st175425@stud.uni-stuttgart.de vpn.tik.uni-stuttgart.de --passwd-on-stdin`\n\n3. Login via ssh\n\nTo make it easy to login, add the following to your `~/.ssh/config` file:\n\n```sshconfig\n# ~/.ssh/config\nHost simtech-hpc\n    Hostname ehlers-login.informatik.uni-stuttgart.de\n    User st123456\n```\n\n4. Install Nix\n\nHave a look at the `setup.sh` script in this repo and after understanding it, you can execute it on the simtech-hpc by running `bash setup.sh`.\nThis might take a few minutes.\nAfterwards, you can use Nix by running `nix-static` (this might require you to open a new shell).\nThis also means, that in every command you want to use Nix, you'd have to substitute `nix` by `nix-static`.\n\n5. Build the iso of the preCICE VM\n\nRemember to use `nix-static` if you are running this on the simtech-hpc after installing nix via the `setup.sh` script.\n\n`nix build '.#nixosConfigurations.\"precice-vm\".config.system.build.iso'`\n\n6. (Optional) Uninstall nix\n\nRead, understand and run the `clean.sh` script in this repo.\n\nTip: You can disable the banner when logging in by executing a `touch ~/.hushlogin`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprecice%2Fnix-packages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprecice%2Fnix-packages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprecice%2Fnix-packages/lists"}