commit be389d27235a8556df14dace7728acd05a4bcd18 Author: adnanioricce Date: Wed Aug 14 14:02:08 2024 -0300 [Init] - adding version control for docs and tutorial follow up diff --git a/adhoc-env.bash b/adhoc-env.bash new file mode 100644 index 0000000..7e39ab1 --- /dev/null +++ b/adhoc-env.bash @@ -0,0 +1,2 @@ +#!/usr/bin/env nix-shell +#! nix-shell -p git neovim nodejs diff --git a/nix-language/AttributeSets/attributeAccess.nix b/nix-language/AttributeSets/attributeAccess.nix new file mode 100644 index 0000000..f2cab6e --- /dev/null +++ b/nix-language/AttributeSets/attributeAccess.nix @@ -0,0 +1,13 @@ +let + attrset = { x = 1; }; +in + attrset.x + +# nested attributes +#let +# attrset2 = { a = { b = { c = 1; }; }; }; +#in +#attrset2.a.b.c + +# nested expression with dot notation +#{ a.b.c = 1; } \ No newline at end of file diff --git a/nix-language/AttributeSets/attributeSet.nix b/nix-language/AttributeSets/attributeSet.nix new file mode 100644 index 0000000..8c0bbe7 --- /dev/null +++ b/nix-language/AttributeSets/attributeSet.nix @@ -0,0 +1,14 @@ +{ + string = "hello"; + integer = 1; + float = 3.141; + bool = true; + null = null; + list = [ 1 "two" false ]; + attribute-set = { + a = "hello"; + b = 2; + c = 2.718; + d = false; + }; # comments are supported +} diff --git a/nix-language/AttributeSets/recursiveAttribute.nix b/nix-language/AttributeSets/recursiveAttribute.nix new file mode 100644 index 0000000..c0afb3e --- /dev/null +++ b/nix-language/AttributeSets/recursiveAttribute.nix @@ -0,0 +1,12 @@ +rec { + one = 1; + two = one + 1; + three = two + 1; +} + +# failing counter-example +#{ +# one = 1; +# two = one + 1; +# three = two + 1; +#} diff --git a/nix-language/Derivations/default.nix b/nix-language/Derivations/default.nix new file mode 100644 index 0000000..d1c7e29 --- /dev/null +++ b/nix-language/Derivations/default.nix @@ -0,0 +1,3 @@ +let + pkgs = import {}; +in "${pkgs.nix}" diff --git a/nix-language/Dockerfile b/nix-language/Dockerfile new file mode 100644 index 0000000..8b0688a --- /dev/null +++ b/nix-language/Dockerfile @@ -0,0 +1,5 @@ +FROM nixos/nix + +RUN nix-channel --updates + +# RUN nix-build -A pythonFull '' \ No newline at end of file diff --git a/nix-language/FileSystemPaths/LookupPaths/default.nix b/nix-language/FileSystemPaths/LookupPaths/default.nix new file mode 100644 index 0000000..adff05f --- /dev/null +++ b/nix-language/FileSystemPaths/LookupPaths/default.nix @@ -0,0 +1,2 @@ +# other name is "angle bracket syntax" + \ No newline at end of file diff --git a/nix-language/FileSystemPaths/LookupPaths/lib.nix b/nix-language/FileSystemPaths/LookupPaths/lib.nix new file mode 100644 index 0000000..ded92a7 --- /dev/null +++ b/nix-language/FileSystemPaths/LookupPaths/lib.nix @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/nix-language/FileSystemPaths/absolute.nix b/nix-language/FileSystemPaths/absolute.nix new file mode 100644 index 0000000..8ca9927 --- /dev/null +++ b/nix-language/FileSystemPaths/absolute.nix @@ -0,0 +1 @@ +/absolute/path \ No newline at end of file diff --git a/nix-language/FileSystemPaths/currentDir.nix b/nix-language/FileSystemPaths/currentDir.nix new file mode 100644 index 0000000..0f6d39d --- /dev/null +++ b/nix-language/FileSystemPaths/currentDir.nix @@ -0,0 +1 @@ +./. \ No newline at end of file diff --git a/nix-language/FileSystemPaths/parentDir.nix b/nix-language/FileSystemPaths/parentDir.nix new file mode 100644 index 0000000..4badd8e --- /dev/null +++ b/nix-language/FileSystemPaths/parentDir.nix @@ -0,0 +1 @@ +../. \ No newline at end of file diff --git a/nix-language/FileSystemPaths/relative.2.nix b/nix-language/FileSystemPaths/relative.2.nix new file mode 100644 index 0000000..b5a2f72 --- /dev/null +++ b/nix-language/FileSystemPaths/relative.2.nix @@ -0,0 +1 @@ +relative/path \ No newline at end of file diff --git a/nix-language/FileSystemPaths/relative.nix b/nix-language/FileSystemPaths/relative.nix new file mode 100644 index 0000000..5a93bb2 --- /dev/null +++ b/nix-language/FileSystemPaths/relative.nix @@ -0,0 +1 @@ +./relative \ No newline at end of file diff --git a/nix-language/FunctionLibraries/addOne.nix b/nix-language/FunctionLibraries/addOne.nix new file mode 100644 index 0000000..25f13fc --- /dev/null +++ b/nix-language/FunctionLibraries/addOne.nix @@ -0,0 +1 @@ +x: x + 1 diff --git a/nix-language/FunctionLibraries/addOneAndTwo.nix b/nix-language/FunctionLibraries/addOneAndTwo.nix new file mode 100644 index 0000000..e0ef584 --- /dev/null +++ b/nix-language/FunctionLibraries/addOneAndTwo.nix @@ -0,0 +1 @@ +1 + 2 diff --git a/nix-language/FunctionLibraries/builtins.nix b/nix-language/FunctionLibraries/builtins.nix new file mode 100644 index 0000000..54c9395 --- /dev/null +++ b/nix-language/FunctionLibraries/builtins.nix @@ -0,0 +1 @@ +builtins.toString \ No newline at end of file diff --git a/nix-language/FunctionLibraries/import.nix b/nix-language/FunctionLibraries/import.nix new file mode 100644 index 0000000..241513d --- /dev/null +++ b/nix-language/FunctionLibraries/import.nix @@ -0,0 +1 @@ +import ./addOneAndTwo.nix \ No newline at end of file diff --git a/nix-language/FunctionLibraries/importImmediately.nix b/nix-language/FunctionLibraries/importImmediately.nix new file mode 100644 index 0000000..845636c --- /dev/null +++ b/nix-language/FunctionLibraries/importImmediately.nix @@ -0,0 +1 @@ +import ./addOne.nix 1 \ No newline at end of file diff --git a/nix-language/FunctionLibraries/pkgs.lib.nix b/nix-language/FunctionLibraries/pkgs.lib.nix new file mode 100644 index 0000000..2db7571 --- /dev/null +++ b/nix-language/FunctionLibraries/pkgs.lib.nix @@ -0,0 +1,8 @@ +# The nixpkgs repository contains an attribute set called lib, +# which provides a large number of useful functions. +# They are implemented in the Nix language +# , as opposed to builtins, which are part of the language itself. +let + pkgs = import {}; +in +pkgs.lib.strings.toUpper "lookup paths considered harmful" \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/additionalAttributes.example.nix b/nix-language/Functions/AttributeSetArgument/additionalAttributes.example.nix new file mode 100644 index 0000000..e0a67a7 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/additionalAttributes.example.nix @@ -0,0 +1,5 @@ +let + f = { a, b, ... }: a + b; +in +f { a = 1; b = 2; c = 3; } + diff --git a/nix-language/Functions/AttributeSetArgument/additionalAttributes.nix b/nix-language/Functions/AttributeSetArgument/additionalAttributes.nix new file mode 100644 index 0000000..2ee5925 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/additionalAttributes.nix @@ -0,0 +1 @@ +{a, b, ...}: a + b \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/counterExample.nix b/nix-language/Functions/AttributeSetArgument/counterExample.nix new file mode 100644 index 0000000..d5e0594 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/counterExample.nix @@ -0,0 +1,4 @@ +let + f = {a, b}: a + b; +in +f { a = 1; b = 2; c = 3; } \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/default.nix b/nix-language/Functions/AttributeSetArgument/default.nix new file mode 100644 index 0000000..e8ec475 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/default.nix @@ -0,0 +1 @@ +{a, b}: a + b \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/defaultValues.emptySet.nix b/nix-language/Functions/AttributeSetArgument/defaultValues.emptySet.nix new file mode 100644 index 0000000..58b960f --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/defaultValues.emptySet.nix @@ -0,0 +1,4 @@ +let + f = {a ? 0, b ? 0}: a + b; +in +f { } # empty attribute set \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/defaultValues.nix b/nix-language/Functions/AttributeSetArgument/defaultValues.nix new file mode 100644 index 0000000..c37e171 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/defaultValues.nix @@ -0,0 +1,4 @@ +let + f = {a, b ? 0}: a + b; +in +f { a = 1; } \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/example.nix b/nix-language/Functions/AttributeSetArgument/example.nix new file mode 100644 index 0000000..07ccd74 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/example.nix @@ -0,0 +1,4 @@ +let + f = {a, b}: a + b; +in +f { a = 1; b = 2; } \ No newline at end of file diff --git a/nix-language/Functions/AttributeSetArgument/namedAttributes.alternative.nix b/nix-language/Functions/AttributeSetArgument/namedAttributes.alternative.nix new file mode 100644 index 0000000..cd6bc41 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/namedAttributes.alternative.nix @@ -0,0 +1,5 @@ +# args@{a,b,...}: a + b + args.c +let + f = {a, b, ...}@args: a + b + args.c; +in +f { a = 1; b = 2; c = 3; } diff --git a/nix-language/Functions/AttributeSetArgument/namedAttributes.nix b/nix-language/Functions/AttributeSetArgument/namedAttributes.nix new file mode 100644 index 0000000..2b8c375 --- /dev/null +++ b/nix-language/Functions/AttributeSetArgument/namedAttributes.nix @@ -0,0 +1 @@ +{a,b,...}@args: a + b + args.c diff --git a/nix-language/Functions/CallingFunctions/functionCall.attrSet.nix b/nix-language/Functions/CallingFunctions/functionCall.attrSet.nix new file mode 100644 index 0000000..e55e324 --- /dev/null +++ b/nix-language/Functions/CallingFunctions/functionCall.attrSet.nix @@ -0,0 +1,5 @@ +let + f = x: x.a; + v = { a = 1; }; +in +f v \ No newline at end of file diff --git a/nix-language/Functions/CallingFunctions/functionCall.nix b/nix-language/Functions/CallingFunctions/functionCall.nix new file mode 100644 index 0000000..377ba69 --- /dev/null +++ b/nix-language/Functions/CallingFunctions/functionCall.nix @@ -0,0 +1,4 @@ +let + f = x: x.a; +in + f {a = 1; } \ No newline at end of file diff --git a/nix-language/Functions/CallingFunctions/functionCall.parenthesis.nix b/nix-language/Functions/CallingFunctions/functionCall.parenthesis.nix new file mode 100644 index 0000000..8b8ec1f --- /dev/null +++ b/nix-language/Functions/CallingFunctions/functionCall.parenthesis.nix @@ -0,0 +1 @@ +(x: x + 1) 1 \ No newline at end of file diff --git a/nix-language/Functions/CallingFunctions/functionOnListWithoutParenthesis.nix b/nix-language/Functions/CallingFunctions/functionOnListWithoutParenthesis.nix new file mode 100644 index 0000000..0186fa6 --- /dev/null +++ b/nix-language/Functions/CallingFunctions/functionOnListWithoutParenthesis.nix @@ -0,0 +1,6 @@ +let + f = x: x + 1; + a = 1; +in +# placing f and a on the list + [ f a ] \ No newline at end of file diff --git a/nix-language/Functions/CallingFunctions/parenthesisOnList.nix b/nix-language/Functions/CallingFunctions/parenthesisOnList.nix new file mode 100644 index 0000000..26a3fe9 --- /dev/null +++ b/nix-language/Functions/CallingFunctions/parenthesisOnList.nix @@ -0,0 +1,7 @@ +let + f = x: x + 1; + a = 1; + +in +# applies f to a + [ (f a) ] diff --git a/nix-language/Functions/MultipleArgs/callingTwoArgFunction.oneValue.nix b/nix-language/Functions/MultipleArgs/callingTwoArgFunction.oneValue.nix new file mode 100644 index 0000000..a21578a --- /dev/null +++ b/nix-language/Functions/MultipleArgs/callingTwoArgFunction.oneValue.nix @@ -0,0 +1,4 @@ +let + f = x: y: x + y; +in +f 1 \ No newline at end of file diff --git a/nix-language/Functions/MultipleArgs/callingTwoArgFunction.twoValue.nix b/nix-language/Functions/MultipleArgs/callingTwoArgFunction.twoValue.nix new file mode 100644 index 0000000..6ecbe60 --- /dev/null +++ b/nix-language/Functions/MultipleArgs/callingTwoArgFunction.twoValue.nix @@ -0,0 +1,4 @@ +let + f = x: y: x + y; +in +f 1 2 \ No newline at end of file diff --git a/nix-language/Functions/MultipleArgs/default.nix b/nix-language/Functions/MultipleArgs/default.nix new file mode 100644 index 0000000..b0ae024 --- /dev/null +++ b/nix-language/Functions/MultipleArgs/default.nix @@ -0,0 +1 @@ +x: y: x + y diff --git a/nix-language/Functions/MultipleArgs/twoArgFunction.nix b/nix-language/Functions/MultipleArgs/twoArgFunction.nix new file mode 100644 index 0000000..f7b2a11 --- /dev/null +++ b/nix-language/Functions/MultipleArgs/twoArgFunction.nix @@ -0,0 +1 @@ +x: y: x + y \ No newline at end of file diff --git a/nix-language/Functions/attributeSetArg.nix b/nix-language/Functions/attributeSetArg.nix new file mode 100644 index 0000000..2cba7ec --- /dev/null +++ b/nix-language/Functions/attributeSetArg.nix @@ -0,0 +1 @@ +{ a, b }: a + b \ No newline at end of file diff --git a/nix-language/Functions/attributeSetArg.withAdditional.nix b/nix-language/Functions/attributeSetArg.withAdditional.nix new file mode 100644 index 0000000..70a1a8a --- /dev/null +++ b/nix-language/Functions/attributeSetArg.withAdditional.nix @@ -0,0 +1 @@ +{ a, b, ...}: a + b \ No newline at end of file diff --git a/nix-language/Functions/attributeSetArg.withDefault.nix b/nix-language/Functions/attributeSetArg.withDefault.nix new file mode 100644 index 0000000..01e74ca --- /dev/null +++ b/nix-language/Functions/attributeSetArg.withDefault.nix @@ -0,0 +1 @@ +{ a, b ? 0 }: a + b \ No newline at end of file diff --git a/nix-language/Functions/default.nix b/nix-language/Functions/default.nix new file mode 100644 index 0000000..14c5c4b --- /dev/null +++ b/nix-language/Functions/default.nix @@ -0,0 +1 @@ +x: x + 1 \ No newline at end of file diff --git a/nix-language/Functions/multipleArgs.nesting.nix b/nix-language/Functions/multipleArgs.nesting.nix new file mode 100644 index 0000000..f7b2a11 --- /dev/null +++ b/nix-language/Functions/multipleArgs.nesting.nix @@ -0,0 +1 @@ +x: y: x + y \ No newline at end of file diff --git a/nix-language/Functions/nameAttributeSetArg.nix b/nix-language/Functions/nameAttributeSetArg.nix new file mode 100644 index 0000000..b84b813 --- /dev/null +++ b/nix-language/Functions/nameAttributeSetArg.nix @@ -0,0 +1,3 @@ +args@{ a,b,... }: a + b + args.c +# or +#{ a,b,...}@args: a + b + args.c \ No newline at end of file diff --git a/nix-language/Functions/namedFunction.nix b/nix-language/Functions/namedFunction.nix new file mode 100644 index 0000000..0dcab75 --- /dev/null +++ b/nix-language/Functions/namedFunction.nix @@ -0,0 +1,3 @@ +let + f = x: x + 1; +in f \ No newline at end of file diff --git a/nix-language/Functions/singleArgument.nix b/nix-language/Functions/singleArgument.nix new file mode 100644 index 0000000..01de18d --- /dev/null +++ b/nix-language/Functions/singleArgument.nix @@ -0,0 +1 @@ +x; x + 1 diff --git a/nix-language/Impurities/data b/nix-language/Impurities/data new file mode 100644 index 0000000..190a180 --- /dev/null +++ b/nix-language/Impurities/data @@ -0,0 +1 @@ +123 diff --git a/nix-language/Impurities/fetchers.nix b/nix-language/Impurities/fetchers.nix new file mode 100644 index 0000000..0c6752e --- /dev/null +++ b/nix-language/Impurities/fetchers.nix @@ -0,0 +1 @@ +builtins.fetchurl "https://github.com/NixOS/nix/archive/7c3ab5751568a0bc63430b33a5169c5e4784a0ff.tar.gz" diff --git a/nix-language/Impurities/fetchers.tarball.nix b/nix-language/Impurities/fetchers.tarball.nix new file mode 100644 index 0000000..422ef82 --- /dev/null +++ b/nix-language/Impurities/fetchers.tarball.nix @@ -0,0 +1 @@ +builtins.fetchTarball "https://github.com/NixOS/nix/archive/7c3ab5751568a0bc63430b33a5169c5e4784a0ff.tar.gz" diff --git a/nix-language/Impurities/paths.nix b/nix-language/Impurities/paths.nix new file mode 100644 index 0000000..222c617 --- /dev/null +++ b/nix-language/Impurities/paths.nix @@ -0,0 +1,4 @@ +#For directories the same thing happens: +#The entire directory (including nested files and directories) is copied to the Nix store +#,and the evaluated string becomes the Nix store path of the directory. +"${./data}" diff --git a/nix-language/IndentedStrings/default.nix b/nix-language/IndentedStrings/default.nix new file mode 100644 index 0000000..4931c53 --- /dev/null +++ b/nix-language/IndentedStrings/default.nix @@ -0,0 +1,5 @@ +'' +multi +line +string +'' \ No newline at end of file diff --git a/nix-language/IndentedStrings/defaultWithSpaces.nix b/nix-language/IndentedStrings/defaultWithSpaces.nix new file mode 100644 index 0000000..c98b599 --- /dev/null +++ b/nix-language/IndentedStrings/defaultWithSpaces.nix @@ -0,0 +1,5 @@ +'' + one + two + three +'' \ No newline at end of file diff --git a/nix-language/Inheritance/inheritance.nix b/nix-language/Inheritance/inheritance.nix new file mode 100644 index 0000000..7c31044 --- /dev/null +++ b/nix-language/Inheritance/inheritance.nix @@ -0,0 +1,30 @@ +#inherit is shorthand for assigning the value of a name from an existing scope +#to the same name in a nested scope. +#It is for convenience to avoid repeating the same name multiple times. +let + x = 1; + y = 2; +in +{ + inherit x y; +} + +# the fragment ```inherit x y;``` is equivalent to: +# ``` x = x;y = y; + +# It is also possible to inherit names from a specific attribute set with parentheses (inherit (...) ...). +#let +# a = { x = 1; y = 2; }; +#in +#{ +# inherit (a) x y; +#} + +# The fragment +#inherit (a) x y; +# is equivalent to +#x = a.x; y = a.y; +# inherit also work inside ``let`` expressions. +#let +# inherit ({ x = 1; y = 2; }) x y; +#in [ x y ] \ No newline at end of file diff --git a/nix-language/README.md b/nix-language/README.md new file mode 100644 index 0000000..de0f341 --- /dev/null +++ b/nix-language/README.md @@ -0,0 +1,2 @@ +# Nix Language Learn +This folder has some files copied from the [nix tutorial](https://nix.dev/tutorials/nix-language.html). For more, search the [nix manual](https://nix.dev/manual/nix/2.18/language/index.html) \ No newline at end of file diff --git a/nix-language/WorkedExamples/nixosConfig.nix b/nix-language/WorkedExamples/nixosConfig.nix new file mode 100644 index 0000000..ba8ca7a --- /dev/null +++ b/nix-language/WorkedExamples/nixosConfig.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: { + + imports = [ ./hardware-configuration.nix ]; + + environment.systemPackages = with pkgs; [ git ]; + + # ... + +} \ No newline at end of file diff --git a/nix-language/WorkedExamples/package.nix b/nix-language/WorkedExamples/package.nix new file mode 100644 index 0000000..7c6a876 --- /dev/null +++ b/nix-language/WorkedExamples/package.nix @@ -0,0 +1,18 @@ +{ lib, stdenv, fetchurl }: + +stdenv.mkDerivation rec { + + pname = "hello"; + + version = "2.12"; + + src = fetchurl { + url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz"; + sha256 = "1ayhp9v4m4rdhjmnl2bq3cibrbqqkgjbl3s7yk2nhlh8vj3ay16g"; + }; + + meta = with lib; { + license = licenses.gpl3Plus; + }; + +} \ No newline at end of file diff --git a/nix-language/WorkedExamples/shellEnv.nix b/nix-language/WorkedExamples/shellEnv.nix new file mode 100644 index 0000000..dd06c55 --- /dev/null +++ b/nix-language/WorkedExamples/shellEnv.nix @@ -0,0 +1,10 @@ +{ pkgs ? import {} }: +let + message = "hello world"; +in +pkgs.mkShellNoCC { + packages = with pkgs; [ cowsay ]; + shellHook = '' + cowsay ${message} + ''; +} \ No newline at end of file diff --git a/nix-language/abc.nix b/nix-language/abc.nix new file mode 100644 index 0000000..06bfdf8 --- /dev/null +++ b/nix-language/abc.nix @@ -0,0 +1 @@ +{ a.b.c = 1; } diff --git a/nix-language/default.nix b/nix-language/default.nix new file mode 100644 index 0000000..e0ef584 --- /dev/null +++ b/nix-language/default.nix @@ -0,0 +1 @@ +1 + 2 diff --git a/nix-language/letin.nix b/nix-language/letin.nix new file mode 100644 index 0000000..2594897 --- /dev/null +++ b/nix-language/letin.nix @@ -0,0 +1,4 @@ +let + a = 1; + in + a + a diff --git a/nix-language/letin_ab.nix b/nix-language/letin_ab.nix new file mode 100644 index 0000000..35fcb79 --- /dev/null +++ b/nix-language/letin_ab.nix @@ -0,0 +1,26 @@ +let + b = a + 1; + a = 1; +in +a + b +# Alternatives: + +# with rec +#rec { +# b = a + 1; +# c = a + b; +# a = 1; +#} + +# lists +#rec { +# b = a + 1; +# c = a + b; +# a = 1; +#} + +# failing counter-exmaple +#{ +# a = let x = 1; in x; +# b = x; +#} \ No newline at end of file diff --git a/nix-language/notesOnWhitespace.nix b/nix-language/notesOnWhitespace.nix new file mode 100644 index 0000000..9e4bc9b --- /dev/null +++ b/nix-language/notesOnWhitespace.nix @@ -0,0 +1,10 @@ +# White space is used to delimit lexical tokens, where required. It is otherwise insignificant. +# Line breaks, indentation, and additional spaces are for readers' convenience. +# the following are equivalent + +#let +# x = 1; +# y = 2; +# in x + y + +let a=1;b=2;in a+b diff --git a/nix-language/oneAndTwo.nix b/nix-language/oneAndTwo.nix new file mode 100644 index 0000000..e0ef584 --- /dev/null +++ b/nix-language/oneAndTwo.nix @@ -0,0 +1 @@ +1 + 2 diff --git a/nix-language/stringInterpolation/confusionWithShell.nix b/nix-language/stringInterpolation/confusionWithShell.nix new file mode 100644 index 0000000..82646e6 --- /dev/null +++ b/nix-language/stringInterpolation/confusionWithShell.nix @@ -0,0 +1,5 @@ +# the $out is a shell script variable +let + out = "Nix"; +in +"echo ${out} > $out" \ No newline at end of file diff --git a/nix-language/stringInterpolation/stringInterpolation.counter.nix b/nix-language/stringInterpolation/stringInterpolation.counter.nix new file mode 100644 index 0000000..fb96061 --- /dev/null +++ b/nix-language/stringInterpolation/stringInterpolation.counter.nix @@ -0,0 +1,4 @@ +let + x = 1; +in +"${x} + ${x} = ${x + x}" \ No newline at end of file diff --git a/nix-language/stringInterpolation/stringInterpolation.nix b/nix-language/stringInterpolation/stringInterpolation.nix new file mode 100644 index 0000000..94575a5 --- /dev/null +++ b/nix-language/stringInterpolation/stringInterpolation.nix @@ -0,0 +1,4 @@ +let + name = "Nix"; +in +"hello ${name}" \ No newline at end of file diff --git a/nix-language/stringInterpolation/stringInterpolationHardToRead.nix b/nix-language/stringInterpolation/stringInterpolationHardToRead.nix new file mode 100644 index 0000000..0d5e785 --- /dev/null +++ b/nix-language/stringInterpolation/stringInterpolationHardToRead.nix @@ -0,0 +1,4 @@ +let + a = "no"; +in +"${a + " ${a + " ${a}"}"}" \ No newline at end of file diff --git a/nix-language/with.nix b/nix-language/with.nix new file mode 100644 index 0000000..8b1a701 --- /dev/null +++ b/nix-language/with.nix @@ -0,0 +1,32 @@ +let + a = { + x = 1; + y = 2; + z = 3; + }; +in +with a; [ x y z ] + +# The following is equivalent to the previous expression +# let +# a = { +# x = 1; +# y = 2; +# z = 3; +# }; +# in +# [ a.x a.y a.z ] + + +# Failing counter exmaple +#let +# a = { +# x = 1; +# y = 2; +# z = 3; +# }; +#in +#{ +# b = with a; [ x y z ]; +# c = x; +#} \ No newline at end of file diff --git a/nixpkgs-releases.sh b/nixpkgs-releases.sh new file mode 100755 index 0000000..805b55e --- /dev/null +++ b/nixpkgs-releases.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash --pure +#! nix-shell -p bash cacert curl jq python3Packages.xmljson +#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/2a601aafdc5605a5133a2ca506a34a3a73377247.tar.gz + +curl https://github.com/NixOS/nixpkgs/releases.atom | xml2json | jq .