diff --git a/courses/day-01-introduction/40-nix-language.org b/courses/day-01-introduction/40-nix-language.org index 0ce880e..d47fe6c 100644 --- a/courses/day-01-introduction/40-nix-language.org +++ b/courses/day-01-introduction/40-nix-language.org @@ -266,7 +266,7 @@ \\ Isn't that delightfully confusing? - + #+BEGIN_SRC nix let function = { a ? 23, ... } @ args: { inherit a; } // args; diff --git a/courses/day-02-builders/50-derivations.org b/courses/day-02-builders/50-derivations.org index 96d02ac..7689f86 100644 --- a/courses/day-02-builders/50-derivations.org +++ b/courses/day-02-builders/50-derivations.org @@ -329,7 +329,7 @@ \\ - 1. Find ~nixpkgs~ on your system (e.g. via ~$NIX_PATH~) + 1. Find ~nixpkgs~ on your system (type ~~ in the repl) 2. ~nixpkgs/pkgs/stdenv/generic/setup.sh~ ** Some less common configuration diff --git a/courses/day-02-builders/53-overrides.org b/courses/day-02-builders/53-overrides.org index ccab8f5..06f4a1f 100644 --- a/courses/day-02-builders/53-overrides.org +++ b/courses/day-02-builders/53-overrides.org @@ -78,6 +78,24 @@ }) #+END_SRC +** + +#+BEGIN_SRC nix + stdenv.mkDerivation (finalAttrs: { + pname = "memtest86+"; + version = "6.00"; + + src = fetchFromGitHub { + owner = "memtest86plus"; + repo = "memtest86plus"; + rev = "v${finalAttrs.version}"; + hash = "sha256-m9oGLXTCaE5CgA4o8MGdjQTQSz/j8kC9BJ84RVcBZjs="; + }; + + # ... + } +#+END_SRC + ** ~overrideDerivation~ \\ diff --git a/courses/day-02-builders/61-overrides.org b/courses/day-02-builders/61-overrides.org index e7a4249..06bfc4f 100644 --- a/courses/day-02-builders/61-overrides.org +++ b/courses/day-02-builders/61-overrides.org @@ -3,8 +3,6 @@ ** -\\ - Take a package from ~nixpkgs~ and roll it back to a previous version. @@ -12,4 +10,47 @@ 2. Figure out the build hash 3. Fix compilation problems that come up (if any) +** Example: eagle 9.6.2 -> 9.5.0 + +\\ + +#+BEGIN_SRC nix + with import { + config.allowUnfree = true; + }; + eagle.overrideAttrs ({ src, version, ... }: { + version = "9.5.0"; + src = + let + url = builtins.replaceStrings ["9.6.2" "9_6_2"] ["9.5.0" "9_5_0"] src.url; + in + pkgs.fetchurl { + inherit url; + sha256 = lib.fakeSha256; + }; + }) +#+END_SRC + +** + +#+BEGIN_SRC shell + these 2 derivations will be built: + /nix/store/3904kh32s3v70xp8wzz0z2ggda16jxy4-Autodesk_EAGLE_9.5.0_English_Linux_64bit.tar.gz.drv + /nix/store/3zayjzjjrjwnp0lpw82v27k66sv1r115-eagle-9.5.0.drv + building '/nix/store/3904kh32s3v70xp8wzz0z2ggda16jxy4-Autodesk_EAGLE_9.5.0_English_Linux_64bit.tar.gz.drv'... + + trying https://eagle-updates.circuits.io/downloads/9_5_0/Autodesk_EAGLE_9.5.0_English_Linux_64bit.tar.gz + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 100 162M 100 162M 0 0 1997k 0 0:01:23 0:01:23 --:--:-- 4547k + error: hash mismatch in fixed-output derivation '/nix/store/3904kh32s3v70xp8wzz0z2ggda16jxy4-Autodesk_EAGLE_9.5.0_English_Linux_64bit.tar.gz.drv': + specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + got: sha256-HmdkMZInYiqeWqRb2IO2pAgQUyKnoXA7e21WlJRUU3E= + error: 1 dependencies of derivation '/nix/store/3zayjzjjrjwnp0lpw82v27k66sv1r115-eagle-9.5.0.drv' failed to build +#+END_SRC + +** + +#+INCLUDE: "./examples/eagle.nix" src nix + ** [[file:README.org][Back to index]] diff --git a/courses/day-02-builders/examples/bat.nix b/courses/day-02-builders/examples/bat.nix new file mode 100644 index 0000000..86fe1cf --- /dev/null +++ b/courses/day-02-builders/examples/bat.nix @@ -0,0 +1,15 @@ +with import {}; + +rustPlatform.buildRustPackage rec { + pname = "bat"; + version = "0.22.1"; + + src = fetchFromGitHub { + owner = "sharkdp"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-xkGGnWjuZ5ZR4Ll+JwgWyKZFboFZ6HKA8GviR3YBAnM="; + }; + + cargoSha256 = "sha256-ye6GH4pcI9h1CNpobUzfJ+2WlqJ98saCdD77AtSGafg="; +} diff --git a/courses/day-02-builders/examples/eagle.nix b/courses/day-02-builders/examples/eagle.nix new file mode 100644 index 0000000..a458af3 --- /dev/null +++ b/courses/day-02-builders/examples/eagle.nix @@ -0,0 +1,13 @@ +with import { config.allowUnfree = true; }; +let changeVersion = string: builtins.replaceStrings ["9.6.2" "9_6_2"] ["9.5.0" "9_5_0"] string; +in +eagle.overrideAttrs ({ src, version, installPhase, ... }: { + version = "9.5.0"; + src = let url = changeVersion src.url; + in pkgs.fetchurl { + inherit url; + sha256 = "sha256-HmdkMZInYiqeWqRb2IO2pAgQUyKnoXA7e21WlJRUU3E="; + }; + + installPhase = (changeVersion installPhase); +}) diff --git a/courses/day-02-builders/examples/pickle.nix b/courses/day-02-builders/examples/pickle.nix new file mode 100644 index 0000000..fe2fc4e --- /dev/null +++ b/courses/day-02-builders/examples/pickle.nix @@ -0,0 +1,12 @@ +buildPythonPackage rec { + version = "0.7.5"; + pname = "pickleshare"; + + src = fetchPypi { + inherit pname version; + sha256 = "87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"; + }; + + ## + # buildInputs = with python3Packages; [ requests flask ]; +} diff --git a/courses/day-03-advanced/30-flakes-intro.org b/courses/day-03-advanced/30-flakes-intro.org index 132e3a9..86a0ed9 100644 --- a/courses/day-03-advanced/30-flakes-intro.org +++ b/courses/day-03-advanced/30-flakes-intro.org @@ -1,4 +1,4 @@ -#+Title: Pinning sources 📌 +#+Title: Flakes ❄️ & pinning sources 📌 #+SETUPFILE: ../../reveal.setup ** How to manage Nix dependencies? @@ -9,8 +9,9 @@ + Local nixpkgs checkout :: this can be quite unreliable. Alternatively you can include a git-submodule or git-subtree in your configuration repository. - + Niv :: Similar to flakes in a lot of ways, but developed by the - community https://github.com/nmattia/niv + + Niv :: Similar to flakes in a lot of ways, but much smaller in + scope. Developed by community members + https://github.com/nmattia/niv + Flakes :: The hot new shit that everyone is talking about ** Subtree & Submodule diff --git a/courses/day-03-advanced/README.org b/courses/day-03-advanced/README.org index 5a41e4f..372b728 100644 --- a/courses/day-03-advanced/README.org +++ b/courses/day-03-advanced/README.org @@ -13,9 +13,9 @@ Today we will cover a few different advanced concepts around Nix. ** Slides -1. [[./70-nixpkgs.org][Nixpkgs]] -2. [[./80-overlays-and-flakes.org][Overlays]] -3. [[file:85-flakes.org][Flakes]] +1. [[./10-nixpkgs.org][Nixpkgs]] +2. [[./20-overlays-and-flakes.org][Overlays]] +3. [[file:30-flakes-intro.org][Flakes]] 4. [[./90-development.org][Nix for developers]] 5. Cross Compilation 1. [[./10-what-is.org][What even _is_ cross compilation??]]