Skip to content

Instantly share code, notes, and snippets.

@haruki7049
Created May 2, 2025 10:35
Show Gist options
  • Save haruki7049/3b742b17c89b51cf3807cf178f3bac2c to your computer and use it in GitHub Desktop.
Save haruki7049/3b742b17c89b51cf3807cf178f3bac2c to your computer and use it in GitHub Desktop.

Prerequire

  • There is useless ability for use Git submodules with Nix flakes
    • It let us built Simula with the query, .?submodules=1#simula, from the nix build command.

Choices we can

  • Then we can choose:
    1. Creates the Nix derivations from another repository. For now I chose this way.
    2. Creates the Nix derivations from local source code. The submodules will be replaced to normal source code, if we choose this way.
    3. Creates the Nix derivations from submodules' source code. This way has an problem which will let us built Simula with .?submodules=1#simula.

Creates the Nix derivations from another repository

I chose this way, because The godot, wlroots, monado and godot-haskell are already in SimulaVR's GitHub repository. I wrote these source code fetching process, by fetchFromGitHub. This Nix function can be get GitHub repository's source code with the submodules.

  src = fetchFromGitHub {
    owner = "SimulaVR";
    repo = "godot-haskell";
    rev = "c4105239909af90758c585d35f2d03f71381fb57";
    hash = lib.fakeHash;
  };

However, this way has a problem; When we create newer commits, Do we change the commit hashes by hand? If we use this way in the future, My answer is yes. Yes, we must change the commit hashes, BY HAND. 皆思う、とてもめんどうくさいと。(We must think, VERY ANNOYING.)

Creates the Nix derivations from local source code

I didn't choose this way, because there are already some submodules we use in SimulaVR's GitHub repository, and the source code copying is troublesome process & large range of influence for the developers.

However this way has a merit; We can write src attribute as ./.

When we choose to use SimulaVR's GitHub repository, we must edit the commit hashes (and source's hash. Don't forget!) BY HAND. the ./. is the path primitive type1, then we can write as the following. ./. isn't needed to write source's hash (Of course it isn't needed to write commit hash).

  src = ./.;

Footnotes

  1. https://nix.dev/manual/nix/2.25/language/types#type-path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment