Initial commit
This commit is contained in:
101
flake-basic/README.md
Normal file
101
flake-basic/README.md
Normal file
@ -0,0 +1,101 @@
|
||||
# flakes
|
||||
|
||||
Do not forget to `git add` the `flake.nix` file! Or you'll face the `does not exist` error.
|
||||
|
||||
```sh
|
||||
> nix flake check
|
||||
|
||||
> nix build
|
||||
|
||||
> nix flake show
|
||||
```
|
||||
|
||||
## Simplying
|
||||
|
||||
First step:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
outputs = inputs: {
|
||||
packages."x86_64-linux".default = derivation {
|
||||
name = "simple";
|
||||
builder = "${inputs.nixpkgs.legacyPackages."x86_64-linux".bash}/bin/bash";
|
||||
args = [ "-c" "echo foo > $out" ];
|
||||
src = ./.;
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Second step:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
outputs = { self, nixpkgs }: {
|
||||
packages."x86_64-linux".default = derivation {
|
||||
name = "simple";
|
||||
builder = "${nixpkgs.legacyPackages."x86_64-linux".bash}/bin/bash";
|
||||
args = [ "-c" "echo foo > $out" ];
|
||||
src = ./.;
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Third:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
in
|
||||
{
|
||||
packages.${system}.default = derivation {
|
||||
name = "simple";
|
||||
builder = "${nixpkgs.legacyPackages.${system}.bash}/bin/bash";
|
||||
args = [ "-c" "echo foo > $out" ];
|
||||
src = ./.;
|
||||
system = system;
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Fourth:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
name = "simple";
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
src = ./.;
|
||||
in
|
||||
{
|
||||
packages.${system}.default = derivation {
|
||||
inherit name src system;
|
||||
builder = with pkgs; "${bash}/bin/bash";
|
||||
args = [ "-c" "echo foo > $out" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
27
flake-basic/flake.lock
generated
Normal file
27
flake-basic/flake.lock
generated
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1710631334,
|
||||
"narHash": "sha256-rL5LSYd85kplL5othxK5lmAtjyMOBg390sGBTb3LRMM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c75037bbf9093a2acb617804ee46320d6d1fea5a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
19
flake-basic/flake.nix
Normal file
19
flake-basic/flake.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
name = "simple";
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
src = ./.;
|
||||
in
|
||||
{
|
||||
packages.${system}.default = derivation {
|
||||
inherit name src system;
|
||||
builder = with pkgs; "${bash}/bin/bash";
|
||||
args = [ "-c" "echo foo > $out" ];
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user