-
Notifications
You must be signed in to change notification settings - Fork 77
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
workaround esp-idf version detection #39
base: master
Are you sure you want to change the base?
Conversation
pkgs/esp-idf/default.nix
Outdated
@@ -1,5 +1,5 @@ | |||
{ rev ? "v5.1.2" | |||
, sha256 ? "sha256-uEf3/3NPH+E39VgQ02AbxTG7nmG5bQlhwk/WcTeAUfg=" | |||
, sha256 ? "sha256-qjZ438LUQLzyQDKkeo4WMO0jxfkFh6dReuLq/6rftpw=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change intentional? I'm trying to test using your fork but this appears to be breaking it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it was working when I made the change. If I rebuild now it also stopped working for me. I will update the hash, and we will see if this fixes the issue for now.
aa89fb4
to
b96f3c2
Compare
Ok, back to the drawing board. The issue is that fetchgit with leaveDotGit is not always reproducible: NixOS/nixpkgs#8567. |
pkgs/esp-idf/default.nix
Outdated
git init . | ||
git config user.email "nixbld@localhost" | ||
git config user.name "nixbld" | ||
git commit --date="1970-01-01 00:00:00" --allow-empty -m "make idf happy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems quite clever. Is it working on your end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting this error now:
To add an exception for this directory, call:
git config --global --add safe.directory /nix/store/mfmmywqch5m4bshhmh5lb01np9yjdlgk-esp-idf-v5.1.2```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried fiddling with this for a few hours but didn't crack it. You can see the things I tried here:
https://github.com/jonahbron/nixpkgs-esp-dev/commits/madmo/?author=jonahbron
Hoping you have more luck!
Seeing other comments around this affecting non-ESP related stuff, might have some useful resources |
For me it is working now. Had a issue with the installPhase script writing to the source dir, which in turn caused some hash issue. |
I can now get into a shell with {
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixpkgs-esp-dev.url = "github:madmo/nixpkgs-esp-dev";
};
outputs = { self, nixpkgs, nixpkgs-esp-dev }: let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
] (system: function (import nixpkgs {inherit system;}));
in {
packages = forAllSystems (pkgs: let
berkeley-db-1_xx = pkgs.fetchFromGitHub {
owner = "pfalcon";
repo = "berkeley-db-1.xx";
rev = "35aaec4418ad78628a3b935885dd189d41ce779b";
sha256 = "sha256-XItxmpXXPgv11LcnL7dty6uq1JctGokHCU8UGG9ic04=";
};
micropython-src = pkgs.fetchFromGitHub {
owner = "micropython";
repo = "micropython";
rev = "v1.22.2";
sha256 = "sha256-67CAR34VrMOzvNkukDeGRnUfoOLO66R37wsrRHjpp5E=";
};
in {
esp32genericc3 = pkgs.stdenv.mkDerivation {
name = "esp32genericc3";
nativeBuildInputs = [
pkgs.git
nixpkgs-esp-dev.packages.${pkgs.system}.esp-idf-esp32c3
];
src = micropython-src;
phases = ["unpackPhase" "patchPhase" "buildPhase"];
patchPhase = ''
rmdir lib/berkeley-db-1.xx
ln -s ${berkeley-db-1_xx} lib/berkeley-db-1.xx
'';
buildPhase = ''
make V=1 -C mpy-cross
make V=1 -C ports/esp32 BOARD=ESP32_GENERIC_C3
'';
};
});
};
} This is incomplete but I can't even get past the buildPhase before it hits the Git error
Any idea why the issue is persisting when run in a derivation? |
@jonahbron This is related to the safe.directory setting of git. I completely disabled this security feature on my machine. |
After hours of fiddling I got it to almost work. But now, it looks like the compiler is trying to download files over the network!
This might be make building purely in a flake a no-go 😢 |
It's not my favorite, but the solution (plus a bunch of other little fixes) was to make it into a known-output derivation; adding a Here is my flake for anyone interested in how it works. Take specific note of the workaround I applied to the Git problem, specifically marking only the correct directory safe, and using the I'd love to see this PR submitted, it's helping me immensely! |
Settled onto what I think is quite a nice Nix expression for this purpose. Hopefully this can be a useful reference so nobody has to burn as much time figuring this out as I have 😄 |
Actually, because I necessarily have to have the Git fix in my project too, this PR has no efffect. Removing it my build still works. https://git.sr.ht/~jonahbron/doorbell/tree/701ca6b16861b7183e72719be843a34308d2cc5b/item/flake.nix @madmo At this point the issue might only be coming down to the "dubious ownership" issue, which I've solved with this code: |
If version.txt is missing some part of the cmake toolchain tries to read refs/heads/fetchgit in the idf repo which failed. This is not a perfect solution, but works nicely when using cargo.
If version.txt is missing some part of the cmake toolchain tries to read refs/heads/fetchgit in the idf repo which failed.
This is not a perfect solution, but works nicely when using cargo, and fixes some of the issues in #5