Skip to content

Commit

Permalink
Update slides for day 2
Browse files Browse the repository at this point in the history
  • Loading branch information
spacekookie committed Jan 31, 2023
1 parent 32652c5 commit e041310
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 10 deletions.
2 changes: 1 addition & 1 deletion courses/day-01-introduction/40-nix-language.org
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
\\

Isn't that delightfully confusing?

#+BEGIN_SRC nix
let
function = { a ? 23, ... } @ args: { inherit a; } // args;
Expand Down
2 changes: 1 addition & 1 deletion courses/day-02-builders/50-derivations.org
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@

\\

1. Find ~nixpkgs~ on your system (e.g. via ~$NIX_PATH~)
1. Find ~nixpkgs~ on your system (type ~<nixpkgs>~ in the repl)
2. ~nixpkgs/pkgs/stdenv/generic/setup.sh~

** Some less common configuration
Expand Down
18 changes: 18 additions & 0 deletions courses/day-02-builders/53-overrides.org
Original file line number Diff line number Diff line change
Expand Up @@ -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~

\\
Expand Down
45 changes: 43 additions & 2 deletions courses/day-02-builders/61-overrides.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,54 @@

**

\\

Take a package from ~nixpkgs~ and roll it back to a previous
version.

1. Change the source
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 <nixpkgs> {
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]]
15 changes: 15 additions & 0 deletions courses/day-02-builders/examples/bat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
with import <nixpkgs> {};

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=";
}
13 changes: 13 additions & 0 deletions courses/day-02-builders/examples/eagle.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with import <nixpkgs> { 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);
})
12 changes: 12 additions & 0 deletions courses/day-02-builders/examples/pickle.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
buildPythonPackage rec {
version = "0.7.5";
pname = "pickleshare";

src = fetchPypi {
inherit pname version;
sha256 = "87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca";
};

##
# buildInputs = with python3Packages; [ requests flask ];
}
7 changes: 4 additions & 3 deletions courses/day-03-advanced/30-flakes-intro.org
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#+Title: Pinning sources 📌
#+Title: Flakes ❄️ & pinning sources 📌
#+SETUPFILE: ../../reveal.setup

** How to manage Nix dependencies?
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions courses/day-03-advanced/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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??]]
Expand Down

0 comments on commit e041310

Please sign in to comment.