Skip to content

Instantly share code, notes, and snippets.

@mixedCase
Created October 28, 2022 20:15
Show Gist options
  • Save mixedCase/58c6690caf25bf2b48f7b675fe9c0c7c to your computer and use it in GitHub Desktop.
Save mixedCase/58c6690caf25bf2b48f7b675fe9c0c7c to your computer and use it in GitHub Desktop.
esp-idf-template reproducer
FROM nixos/nix
# Prepare Nix
RUN mkdir -p /etc/nix && \
echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf && \
echo 'sandbox = false' >> /etc/nix/nix.conf
# Prepare user environment
RUN mkdir -p /test && \
mkdir -p /root/.cargo/bin && \
echo 'export PATH="$PATH:/root/.cargo/bin"' > /root/.bash_profile
WORKDIR /test
# Set up dependencies
COPY flake.* ./
COPY shell.nix ./
RUN nix-shell --run \
'rustup toolchain install nightly --component rust-src'
RUN nix-shell --run \
'cargo install ldproxy'
# Drop user into shell with all deps ready to go
CMD ["nix", "develop"]
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1666879188,
"narHash": "sha256-x4XAX5ttuVKfRZMhzY5nxRJnL9qHN5fWdrFwnd0ZQEM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3671af8f1fedccb6ff41694dede93283e5f8611f",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-esp-dev": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1660348774,
"narHash": "sha256-6lXywim2UUXI2tFraRnXgFRpIBZJ4ozkgzIhQJYG63Q=",
"owner": "mirrexagon",
"repo": "nixpkgs-esp-dev",
"rev": "24d03f77bfae3871098fa8c17789fa5a56ae7101",
"type": "github"
},
"original": {
"owner": "mirrexagon",
"repo": "nixpkgs-esp-dev",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1636377693,
"narHash": "sha256-mxnUQZEA361xcupT9RIEcWrNer/+Ik/pbRMDmdRr8gQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c11d08f02390aab49e7c22e6d0ea9b176394d961",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nixpkgs-esp-dev": "nixpkgs-esp-dev"
}
}
},
"root": "root",
"version": 7
}
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs-esp-dev.url = "github:mirrexagon/nixpkgs-esp-dev";
};
outputs = { self, flake-compat, nixpkgs, flake-utils, nixpkgs-esp-dev, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ nixpkgs-esp-dev.overlay ];
pkgs = import nixpkgs {
inherit system overlays;
};
in {
devShell = pkgs.mkShell rec {
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
buildInputs = with pkgs; [
# tools for reproducer
neovim
rustup
rust-analyzer
cargo-generate
cargo-espflash
cargo-espmonitor
clang
# slint dependencies
cmake
pkg-config
fontconfig
xorg.libxcb
wayland
libxkbcommon
libGL
# esp-idf-sys dependencies:
cmake
ninja
python3Packages.python
python3Packages.pip
python3Packages.virtualenv
(gcc-riscv32-esp32c3-elf-bin.override {
version = "2021r2-patch5";
hash = "sha256-99c+X54t8+psqOLJXWym0j1rOP0QHqXTAS88s81Z858=";
})
];
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
};
});
}
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).shellNix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment