Compare commits
1 commit
main
...
lix-compat
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4c3af09fb7 |
13 changed files with 166 additions and 1499 deletions
30
README.md
30
README.md
|
@ -1,9 +1,10 @@
|
|||
[Installation](#installation)
|
||||
|
||||
# 🍵 mynixos-extra-modules
|
||||
# 🍵 nixos-extra-modules
|
||||
|
||||
This repository contains extra modules for `mynixos` that are very opinionated and mainly useful to me and is used in [`sokai/mynixos-config`](https://git.mediani.de/sokai/mynixos-config).
|
||||
All modules in here are opt-in, so nothing will be changed unless you decide you want to use that specific module.
|
||||
This repository contains extra modules for nixos that are very opinionated and mainly
|
||||
useful to me and my colleagues. All modules in here are opt-in, so nothing will
|
||||
be changed unless you decide you want to use that specific module.
|
||||
|
||||
## Overview
|
||||
|
||||
|
@ -30,9 +31,12 @@ Wallpapers | Module | [Link](./hm-modules/wallpapers.nix) | - | - | A simple wal
|
|||
|
||||
## Installation
|
||||
|
||||
To use the extra modules, you will have to add this project to your `flake.nix`, and import the provided main NixOS module in your hosts. Afterwards the new options will be available.
|
||||
To use the extra modules, you will have to add this project to your `flake.nix`,
|
||||
and import the provided main NixOS module in your hosts. Afterwards the new options
|
||||
will be available.
|
||||
|
||||
Certain modules may require the use of additional flakes. In particular depending on the modules you want to use, you might need:
|
||||
Certain modules may require the use of additional flakes. In particular
|
||||
depending on the modules you want to use, you might need:
|
||||
|
||||
- [agenix](https://github.com/ryantm/agenix)
|
||||
- [agenix-rekey](https://github.com/oddlama/agenix-rekey)
|
||||
|
@ -41,9 +45,13 @@ Certain modules may require the use of additional flakes. In particular dependin
|
|||
- [impermanence](https://github.com/nix-community/impermanence)
|
||||
- [microvm.nix](https://github.com/astro/microvm.nix)
|
||||
|
||||
You also must have a `specialArgs.inputs` that refers to all of your flake's inputs, and `inputs.self.pkgs.${system}` must refer to an initialized package set for that specific system that includes extra-modules as an overlay.
|
||||
You also must have a `specialArgs.inputs` that refers to all of your flake's inputs,
|
||||
and `inputs.self.pkgs.${system}` must refer to an initialized package set for that
|
||||
specific system that includes extra-modules as an overlay.
|
||||
|
||||
All cross-node configuration modules (like wireguard) require you to expose all relevant nodes in your flake as `inputs.self.nodes`, so their configuration can be accessed by other nodes.
|
||||
All cross-node configuration modules (like wireguard) require you to expose
|
||||
all relevant nodes in your flake as `inputs.self.nodes`, so their configuration
|
||||
can be accessed by other nodes.
|
||||
|
||||
Here's an example configuration:
|
||||
|
||||
|
@ -52,14 +60,13 @@ Here's an example configuration:
|
|||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# TODO: "nixos-extra-modules" → "mynixos-extra-modules"?
|
||||
nixos-extra-modules = {
|
||||
url = "git+ssh://git@git.mediani.de/sokai/mynixos-extra-modules";
|
||||
url = "github:oddlama/nixos-extra-modules";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
};
|
||||
|
||||
nixpkgs.url = "git+ssh://git@git.mediani.de/mirrors/NixOS_nixpkgs?ref=nixos-25.05";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
# Additional inputs, may or may not be needed for a particular module or extension.
|
||||
# Enable what you use.
|
||||
|
@ -103,7 +110,7 @@ Here's an example configuration:
|
|||
...
|
||||
} @ inputs: {
|
||||
# Example system configuration
|
||||
nixosConfigurations.myhostname = let
|
||||
nixosConfigurations.yourhostname = let
|
||||
system = "x86_64-linux";
|
||||
pkgs = self.pkgs.${system};
|
||||
in nixpkgs.lib.nixosSystem {
|
||||
|
@ -146,4 +153,3 @@ Here's an example configuration:
|
|||
}
|
||||
}
|
||||
```
|
||||
… or have a look at the **original**: [`oddlama/nix-config`](https://github.com/oddlama/nix-config) <3 :)
|
625
flake.lock
generated
625
flake.lock
generated
|
@ -1,46 +1,5 @@
|
|||
{
|
||||
"nodes": {
|
||||
"blank": {
|
||||
"locked": {
|
||||
"lastModified": 1625557891,
|
||||
"narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=",
|
||||
"owner": "divnix",
|
||||
"repo": "blank",
|
||||
"rev": "5a5d2684073d9f563072ed07c871d577a6c614a8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "blank",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"paisano-mdbook-preprocessor",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676162383,
|
||||
"narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
@ -61,115 +20,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell_2": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nixt",
|
||||
"std",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682700442,
|
||||
"narHash": "sha256-qjaAAcCYgp1pBBG7mY9z95ODUBZMtUpf0Qp3Gt/Wha0=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "fb6673fe9fe4409e3f43ca86968261e970918a83",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"dmerge": {
|
||||
"inputs": {
|
||||
"haumea": "haumea",
|
||||
"namaka": "namaka",
|
||||
"nixlib": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
],
|
||||
"yants": [
|
||||
"nixt",
|
||||
"std",
|
||||
"yants"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1684178600,
|
||||
"narHash": "sha256-EtSQcCHRQUBBEj4vbYU0vgPUYiKP261ero5k1QfQ3Bc=",
|
||||
"owner": "divnix",
|
||||
"repo": "dmerge",
|
||||
"rev": "ac9932f26325afac5baa59cf6478432d17762a4e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"ref": "0.2.0",
|
||||
"repo": "dmerge",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1677306201,
|
||||
"narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "0923f0c162f65ae40261ec940406049726cfeab4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_3": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
|
@ -203,36 +54,6 @@
|
|||
"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": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
@ -254,147 +75,13 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"haumea": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"dmerge",
|
||||
"nixlib"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681176209,
|
||||
"narHash": "sha256-bJLDun6esIyWtwRVXcsgzGbh4UKu8wJDrPgykqPyzmg=",
|
||||
"owner": "nix-community",
|
||||
"repo": "haumea",
|
||||
"rev": "b915b66b27da3a595d77b139e945bb0a2fcac926",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "haumea",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"incl": {
|
||||
"inputs": {
|
||||
"nixlib": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669263024,
|
||||
"narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=",
|
||||
"owner": "divnix",
|
||||
"repo": "incl",
|
||||
"rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "incl",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"n2c": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nixt",
|
||||
"std",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1677330646,
|
||||
"narHash": "sha256-hUYCwJneMjnxTvj30Fjow6UMJUITqHlpUGpXMPXUJsU=",
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"rev": "ebca8f58d450cae1a19c07701a5a8ae40afc9efc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"namaka": {
|
||||
"inputs": {
|
||||
"haumea": [
|
||||
"nixt",
|
||||
"std",
|
||||
"dmerge",
|
||||
"haumea"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"dmerge",
|
||||
"nixlib"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1683059428,
|
||||
"narHash": "sha256-ZTMqleCWmuNWhZE375gtF1j1JRkaKEUFN1AM43e7h4Y=",
|
||||
"owner": "nix-community",
|
||||
"repo": "namaka",
|
||||
"rev": "2deba2f416454aec770bc1cc7365e39c73e6b1d7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "v0.1.1",
|
||||
"repo": "namaka",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nixt",
|
||||
"std",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixago-exts": [
|
||||
"nixt",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1683210100,
|
||||
"narHash": "sha256-bhGDOlkWtlhVECpoOog4fWiFJmLCpVEg09a40aTjCbw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"rev": "1da60ad9412135f9ed7a004669fdcf3d378ec630",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1737885589,
|
||||
"narHash": "sha256-Zf0hSrtzaM1DEz8//+Xs51k/wdSajticVrATqDrfQjg=",
|
||||
"lastModified": 1739214665,
|
||||
"narHash": "sha256-26L8VAu3/1YRxS8MHgBOyOM8xALdo6N0I04PgorE7UM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "852ff1d9e153d8875a83602e03fdef8a63f0ecf8",
|
||||
"rev": "64e75cd44acf21c7933d61d7721e812eac1b5a0a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -416,170 +103,9 @@
|
|||
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1677063315,
|
||||
"narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "988cc958c57ce4350ec248d2d53087777f9e1949",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixt": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"std": "std",
|
||||
"std-data-collection": "std-data-collection"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1729273076,
|
||||
"narHash": "sha256-h2Y+5bikSXS8MPYpxyZpd+VX9H5uuCS/csMMxZCoS3c=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixt",
|
||||
"rev": "ad8863c9f9e5a166d663f2f1f0eef74ab913a883",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixt",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nosys": {
|
||||
"locked": {
|
||||
"lastModified": 1668010795,
|
||||
"narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=",
|
||||
"owner": "divnix",
|
||||
"repo": "nosys",
|
||||
"rev": "feade0141487801c71ff55623b421ed535dbdefa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "nosys",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"paisano": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
],
|
||||
"nosys": "nosys",
|
||||
"yants": [
|
||||
"nixt",
|
||||
"std",
|
||||
"yants"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1678949904,
|
||||
"narHash": "sha256-oAoF66hYYz1RPh3lEwb9/4e4iyBAfTbQKZRRQ8gP0Ds=",
|
||||
"owner": "paisano-nix",
|
||||
"repo": "core",
|
||||
"rev": "88f2aff10a5064551d1d4cb86800d17084489ce3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "paisano-nix",
|
||||
"repo": "core",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"paisano-actions": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"paisano-mdbook-preprocessor",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1677306424,
|
||||
"narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=",
|
||||
"owner": "paisano-nix",
|
||||
"repo": "actions",
|
||||
"rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "paisano-nix",
|
||||
"repo": "actions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"paisano-mdbook-preprocessor": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"fenix": "fenix",
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
],
|
||||
"paisano-actions": "paisano-actions",
|
||||
"std": [
|
||||
"nixt",
|
||||
"std"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1680654400,
|
||||
"narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=",
|
||||
"owner": "paisano-nix",
|
||||
"repo": "mdbook-paisano-preprocessor",
|
||||
"rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "paisano-nix",
|
||||
"repo": "mdbook-paisano-preprocessor",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"paisano-tui": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"std": [
|
||||
"nixt",
|
||||
"std"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681847764,
|
||||
"narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=",
|
||||
"owner": "paisano-nix",
|
||||
"repo": "tui",
|
||||
"rev": "3096bad91cae73ab8ab3367d31f8a143d248a244",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "paisano-nix",
|
||||
"ref": "0.1.1",
|
||||
"repo": "tui",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-compat": "flake-compat",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
|
@ -604,151 +130,8 @@
|
|||
"devshell": "devshell",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixt": "nixt",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1677221702,
|
||||
"narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nixt",
|
||||
"std",
|
||||
"paisano-mdbook-preprocessor",
|
||||
"crane",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"paisano-mdbook-preprocessor",
|
||||
"crane",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1675391458,
|
||||
"narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"std": {
|
||||
"inputs": {
|
||||
"arion": [
|
||||
"nixt",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"blank": "blank",
|
||||
"devshell": "devshell_2",
|
||||
"dmerge": "dmerge",
|
||||
"flake-utils": "flake-utils",
|
||||
"incl": "incl",
|
||||
"makes": [
|
||||
"nixt",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"microvm": [
|
||||
"nixt",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"n2c": "n2c",
|
||||
"nixago": "nixago",
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"nixpkgs"
|
||||
],
|
||||
"paisano": "paisano",
|
||||
"paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor",
|
||||
"paisano-tui": "paisano-tui",
|
||||
"yants": "yants"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1684180498,
|
||||
"narHash": "sha256-kA58ms4yunOVPhe3r7V0IIKeWUV+vl4r2GTcfFfYW5o=",
|
||||
"owner": "divnix",
|
||||
"repo": "std",
|
||||
"rev": "45b431ae09df98e046bcc8271aa209bdfc87444d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "std",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"std-data-collection": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"nixpkgs"
|
||||
],
|
||||
"std": [
|
||||
"nixt",
|
||||
"std"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676163535,
|
||||
"narHash": "sha256-xofkWLBqU4zj5vzJhWor2Z9CyPGKt7UGkTchsCT48Po=",
|
||||
"owner": "divnix",
|
||||
"repo": "std-data-collection",
|
||||
"rev": "f713d81a6197e1b0854fb201cc7acde5ef9e93d4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "std-data-collection",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"yants": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixt",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1667096281,
|
||||
"narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=",
|
||||
"owner": "divnix",
|
||||
"repo": "yants",
|
||||
"rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "yants",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
20
flake.nix
20
flake.nix
|
@ -15,10 +15,6 @@
|
|||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nixt = {
|
||||
url = "github:nix-community/nixt";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
@ -32,18 +28,6 @@
|
|||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
flake.__nixt = inputs.nixt.lib.grow {
|
||||
blocks = import ./tests {
|
||||
inherit (inputs) nixt;
|
||||
pkgs = import inputs.nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
overlays = [
|
||||
self.overlays.default
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake.modules = {
|
||||
flake = {
|
||||
|
@ -92,10 +76,6 @@
|
|||
package = statix;
|
||||
help = "Lint nix code";
|
||||
}
|
||||
{
|
||||
package = inputs.nixt.packages.${system}.default;
|
||||
help = "Lint nix code";
|
||||
}
|
||||
{
|
||||
package = deadnix;
|
||||
help = "Find unused expressions in nix code";
|
||||
|
|
10
lib/misc.nix
10
lib/misc.nix
|
@ -1,4 +1,4 @@
|
|||
_inputs: final: prev:
|
||||
_inputs: _final: prev:
|
||||
let
|
||||
inherit (prev.lib)
|
||||
filter
|
||||
|
@ -6,12 +6,9 @@ let
|
|||
genAttrs
|
||||
mergeAttrs
|
||||
mkMerge
|
||||
stringToCharacters
|
||||
substring
|
||||
unique
|
||||
;
|
||||
inherit (final.lib)
|
||||
bit
|
||||
stringToCharacters
|
||||
;
|
||||
|
||||
# Counts how often each element occurrs in xs.
|
||||
|
@ -63,7 +60,8 @@ let
|
|||
|
||||
# Converts the given hex string to an integer. Only reliable for inputs in [0, 2^63),
|
||||
# after that the sign bit will overflow.
|
||||
hexToDec = v: foldl' (acc: x: (bit.left acc 4) + hexLiteralValues.${x}) 0 (stringToCharacters v);
|
||||
hexToDec =
|
||||
v: foldl' (acc: x: (builtins.bitShiftLeft acc 4) + hexLiteralValues.${x}) 0 (stringToCharacters v);
|
||||
in
|
||||
{
|
||||
lib = prev.lib // {
|
||||
|
|
103
lib/net.nix
103
lib/net.nix
|
@ -19,10 +19,6 @@ let
|
|||
substring
|
||||
unique
|
||||
warnIf
|
||||
;
|
||||
|
||||
# From misc.nix
|
||||
inherit (prev.lib)
|
||||
hexToDec
|
||||
;
|
||||
|
||||
|
@ -43,7 +39,6 @@ in
|
|||
implementations
|
||||
parsers
|
||||
;
|
||||
|
||||
net = recursiveUpdate (removeAttrs libNet.net [ "types" ]) {
|
||||
cidr = rec {
|
||||
# host :: (ip | mac | integer) -> cidr -> ip
|
||||
|
@ -67,13 +62,9 @@ in
|
|||
i: n:
|
||||
let
|
||||
cap = libNet.net.cidr.capacity n;
|
||||
intCheck = builtins.isInt i -> (i >= (-cap) && i < cap);
|
||||
ipCheck = libNet.net.types.ip.check i -> ((libNet.net.types.ip-in n).check result);
|
||||
|
||||
result = libNet.net.cidr.host i n;
|
||||
in
|
||||
assert assertMsg (ipCheck && intCheck) "The host ${toString i} lies outside of ${n}";
|
||||
result;
|
||||
assert assertMsg (i >= (-cap) && i < cap) "The host ${toString i} lies outside of ${n}";
|
||||
libNet.net.cidr.host i n;
|
||||
# hostCidr :: (ip | mac | integer) -> cidr -> cidr
|
||||
#
|
||||
# Returns the nth host in the given cidr range (like cidr.host)
|
||||
|
@ -185,94 +176,6 @@ in
|
|||
cidrv4 = mergev4 v4_and_v6.wrong;
|
||||
cidrv6 = mergev6 v4_and_v6.right;
|
||||
};
|
||||
# assignIps :: cidr -> [int | ip] -> [string] -> [ip]
|
||||
#
|
||||
# Assigns a semi-stable ip address from the given cidr network to each hostname.
|
||||
# The algorithm is based on hashing (abusing sha256) with linear probing.
|
||||
# The order of hosts doesn't matter. No ip (or offset) from the reserved list
|
||||
# will be assigned. The network address and broadcast address will always be reserved
|
||||
# automatically.
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# > net.cidr.assignIps "192.168.100.1/24" [] ["a" "b" "c"]
|
||||
# { a = "192.168.100.202"; b = "192.168.100.74"; c = "192.168.100.226"; }
|
||||
#
|
||||
# > net.cidr.assignIps "192.168.100.1/24" [] ["a" "b" "c" "a-new-elem"]
|
||||
# { a = "192.168.100.202"; a-new-elem = "192.168.100.88"; b = "192.168.100.74"; c = "192.168.100.226"; }
|
||||
#
|
||||
# > net.cidr.assignIps "192.168.100.1/24" [202 "192.168.100.74"] ["a" "b" "c"]
|
||||
# { a = "192.168.100.203"; b = "192.168.100.75"; c = "192.168.100.226"; }
|
||||
assignIps =
|
||||
net: reserved: hosts:
|
||||
let
|
||||
cidrSize = libNet.net.cidr.size net;
|
||||
capacity = libNet.net.cidr.capacity net;
|
||||
# The base address of the network. Used to convert ip-based reservations to offsets
|
||||
baseAddr = host 0 net;
|
||||
# Reserve some values for the network, host and broadcast address.
|
||||
# The network and broadcast address should never be used, and we
|
||||
# want to reserve the host address for the host. We also convert
|
||||
# any ips to offsets here.
|
||||
init = unique (
|
||||
[
|
||||
0
|
||||
(capacity - 1)
|
||||
]
|
||||
++ flip map reserved (x: if builtins.typeOf x == "int" then x else -(libNet.net.ip.diff baseAddr x))
|
||||
);
|
||||
nHosts = builtins.length hosts;
|
||||
nInit = builtins.length init;
|
||||
# Pre-sort all hosts, to ensure ordering invariance
|
||||
sortedHosts =
|
||||
warnIf ((nInit + nHosts) > 0.3 * capacity)
|
||||
"assignIps: hash stability may be degraded since utilization is >30%"
|
||||
(builtins.sort builtins.lessThan hosts);
|
||||
# Generates a hash (i.e. offset value) for a given hostname
|
||||
hashElem =
|
||||
x:
|
||||
builtins.bitAnd (capacity - 1) (
|
||||
hexToDec (builtins.substring 0 16 (builtins.hashString "sha256" x))
|
||||
);
|
||||
# Do linear probing. Returns the first unused value at or after the given value.
|
||||
probe =
|
||||
avoid: value:
|
||||
if
|
||||
elem value avoid
|
||||
# TODO lib.mod
|
||||
# Poor man's modulo, because nix has no modulo. Luckily we operate on a residue
|
||||
# class of x modulo 2^n, so we can use bitAnd instead.
|
||||
then
|
||||
probe avoid (builtins.bitAnd (capacity - 1) (value + 1))
|
||||
else
|
||||
value;
|
||||
# Hash a new element and avoid assigning any existing values.
|
||||
assignOne =
|
||||
{
|
||||
assigned,
|
||||
used,
|
||||
}:
|
||||
x:
|
||||
let
|
||||
value = probe used (hashElem x);
|
||||
in
|
||||
{
|
||||
assigned = assigned // {
|
||||
${x} = host value net;
|
||||
};
|
||||
used = [ value ] ++ used;
|
||||
};
|
||||
in
|
||||
assert assertMsg (
|
||||
cidrSize >= 2 && cidrSize <= 62
|
||||
) "assignIps: cidrSize=${toString cidrSize} is not in [2, 62].";
|
||||
assert assertMsg (nHosts <= capacity - nInit)
|
||||
"assignIps: number of hosts (${toString nHosts}) must be <= capacity (${toString capacity}) - reserved (${toString nInit})";
|
||||
# Assign an ip in the subnet to each element, in order
|
||||
(foldl' assignOne {
|
||||
assigned = { };
|
||||
used = init;
|
||||
} sortedHosts).assigned;
|
||||
};
|
||||
ip = rec {
|
||||
# Checks whether the given address (with or without cidr notation) is an ipv4 address.
|
||||
|
@ -311,7 +214,7 @@ in
|
|||
assignMacs =
|
||||
base: size: reserved: hosts:
|
||||
let
|
||||
capacity = libNet.bit.left 1 size;
|
||||
capacity = builtins.bitShiftLeft 1 size;
|
||||
baseAsInt = libNet.net.mac.diff base "00:00:00:00:00:00";
|
||||
init = unique (
|
||||
flip map reserved (x: if builtins.typeOf x == "int" then x else libNet.net.mac.diff x base)
|
||||
|
|
224
lib/netu.nix
224
lib/netu.nix
|
@ -2,13 +2,10 @@
|
|||
lib ? null,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
net =
|
||||
{
|
||||
ip = {
|
||||
|
||||
# add :: (ip | mac | integer) -> ip -> ip
|
||||
#
|
||||
# Examples:
|
||||
|
@ -96,7 +93,6 @@ let
|
|||
};
|
||||
|
||||
mac = {
|
||||
|
||||
# add :: (ip | mac | integer) -> mac -> mac
|
||||
#
|
||||
# Examples:
|
||||
|
@ -123,7 +119,7 @@ let
|
|||
delta' = typechecks.numeric function "delta" delta;
|
||||
mac' = typechecks.mac function "mac" mac;
|
||||
in
|
||||
builders.mac (arithmetic.add delta' mac');
|
||||
builders.mac (implementations.mac.add delta' mac');
|
||||
|
||||
# diff :: mac -> mac -> integer
|
||||
#
|
||||
|
@ -141,7 +137,7 @@ let
|
|||
minuend' = typechecks.mac function "minuend" minuend;
|
||||
subtrahend' = typechecks.mac function "subtrahend" subtrahend;
|
||||
in
|
||||
arithmetic.diff minuend' subtrahend';
|
||||
implementations.mac.diff minuend' subtrahend';
|
||||
|
||||
# subtract :: (ip | mac | integer) -> mac -> mac
|
||||
#
|
||||
|
@ -159,7 +155,7 @@ let
|
|||
delta' = typechecks.numeric function "delta" delta;
|
||||
mac' = typechecks.mac function "mac" mac;
|
||||
in
|
||||
builders.mac (arithmetic.subtract delta' mac');
|
||||
builders.mac (implementations.mac.subtract delta' mac');
|
||||
};
|
||||
|
||||
cidr = {
|
||||
|
@ -334,7 +330,6 @@ let
|
|||
cidr' = typechecks.cidr function "cidr" cidr;
|
||||
in
|
||||
builders.cidr (implementations.cidr.subnet length' netnum' cidr');
|
||||
|
||||
};
|
||||
}
|
||||
// (
|
||||
|
@ -344,7 +339,6 @@ let
|
|||
{
|
||||
types =
|
||||
let
|
||||
|
||||
mkParsedOptionType =
|
||||
{
|
||||
name,
|
||||
|
@ -385,10 +379,8 @@ let
|
|||
// {
|
||||
description = type.description + " in ${builtins.concatStringsSep " or " cidrs}";
|
||||
};
|
||||
|
||||
in
|
||||
rec {
|
||||
|
||||
ip = mkParsedOptionType {
|
||||
name = "ip";
|
||||
description = "IPv4 or IPv6 address";
|
||||
|
@ -449,7 +441,6 @@ let
|
|||
parser = parsers.mac;
|
||||
builder = builders.mac;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
);
|
||||
|
@ -460,23 +451,43 @@ let
|
|||
|
||||
bit =
|
||||
let
|
||||
inherit (import ./shift.nix) left arithmeticRight logicalRight;
|
||||
leftOrArithRight = a: if a > 0 then left a else arithmeticRight (-a);
|
||||
arithRightOrLeft = a: if a > 0 then arithmeticRight a else left (-a);
|
||||
left =
|
||||
a: b:
|
||||
if a >= 64 then
|
||||
0
|
||||
else if a < 0 then
|
||||
right (-a) b
|
||||
else
|
||||
builtins.bitShiftLeft b a;
|
||||
|
||||
not = builtins.bitXor (-1);
|
||||
right =
|
||||
a: b:
|
||||
if a >= 64 then
|
||||
0
|
||||
else if a < 0 then
|
||||
left (-a) b
|
||||
else
|
||||
builtins.bitShiftRight b a;
|
||||
|
||||
mask = n: builtins.bitAnd (left n 1 - 1);
|
||||
and = builtins.bitAnd;
|
||||
|
||||
or = builtins.bitOr;
|
||||
|
||||
xor = builtins.bitXor;
|
||||
|
||||
not = xor (-1);
|
||||
|
||||
mask = n: and (left n 1 - 1);
|
||||
in
|
||||
{
|
||||
inherit
|
||||
left
|
||||
arithmeticRight
|
||||
logicalRight
|
||||
right
|
||||
and
|
||||
or
|
||||
xor
|
||||
not
|
||||
mask
|
||||
leftOrArithRight
|
||||
arithRightOrLeft
|
||||
;
|
||||
};
|
||||
|
||||
|
@ -492,7 +503,6 @@ let
|
|||
|
||||
parsers =
|
||||
let
|
||||
|
||||
# fmap :: (a -> b) -> parser a -> parser b
|
||||
fmap = f: ma: bind ma (a: pure (f a));
|
||||
|
||||
|
@ -523,10 +533,10 @@ let
|
|||
ap = liftA2 (a: a);
|
||||
|
||||
# then_ :: parser a -> parser b -> parser b
|
||||
then_ = liftA2 (_: b: b);
|
||||
then_ = liftA2 (a: b: b);
|
||||
|
||||
# empty :: parser a
|
||||
empty = _: null;
|
||||
empty = string: null;
|
||||
|
||||
# alt :: parser a -> parser a -> parser a
|
||||
alt =
|
||||
|
@ -641,7 +651,7 @@ let
|
|||
};
|
||||
|
||||
fromDecimalDigits = builtins.foldl' (a: c: a * 10 + c) 0;
|
||||
fromHexadecimalDigits = builtins.foldl' (a: builtins.bitOr (bit.left 4 a)) 0;
|
||||
fromHexadecimalDigits = builtins.foldl' (a: bit.or (bit.left 4 a)) 0;
|
||||
|
||||
# disallow leading zeros
|
||||
decimal = bind (digit decimalDigits) (
|
||||
|
@ -663,7 +673,7 @@ let
|
|||
octet' = then_ dot octet;
|
||||
|
||||
fromOctets = a: b: c: d: {
|
||||
ipv4 = builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 a) b)) c)) d;
|
||||
ipv4 = bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 a) b)) c)) d;
|
||||
};
|
||||
in
|
||||
liftA4 fromOctets octet octet' octet' octet';
|
||||
|
@ -676,6 +686,8 @@ let
|
|||
|
||||
hextet = limit 4 hexadecimal;
|
||||
|
||||
hextet' = then_ colon hextet;
|
||||
|
||||
fromHextets =
|
||||
hextets:
|
||||
if builtins.length hextets != 8 then
|
||||
|
@ -693,17 +705,17 @@ let
|
|||
in
|
||||
pure {
|
||||
ipv6 = {
|
||||
a = builtins.bitOr (bit.left 16 a) b;
|
||||
b = builtins.bitOr (bit.left 16 c) d;
|
||||
c = builtins.bitOr (bit.left 16 e) f;
|
||||
d = builtins.bitOr (bit.left 16 g) h;
|
||||
a = bit.or (bit.left 16 a) b;
|
||||
b = bit.or (bit.left 16 c) d;
|
||||
c = bit.or (bit.left 16 e) f;
|
||||
d = bit.or (bit.left 16 g) h;
|
||||
};
|
||||
};
|
||||
|
||||
ipv4' = fmap (
|
||||
address:
|
||||
let
|
||||
upper = bit.arithmeticRight 16 address.ipv4;
|
||||
upper = bit.right 16 address.ipv4;
|
||||
lower = bit.mask 16 address.ipv4;
|
||||
in
|
||||
[
|
||||
|
@ -738,7 +750,6 @@ let
|
|||
afterDoubleColon = alt ipv4' (
|
||||
liftA2 list.cons hextet (alt (then_ colon afterDoubleColon) (pure [ ]))
|
||||
);
|
||||
|
||||
in
|
||||
bind (alt (then_ (string "::") (doubleColon 0)) (part 0)) fromHextets;
|
||||
|
||||
|
@ -759,11 +770,10 @@ let
|
|||
octet' = then_ colon octet;
|
||||
|
||||
fromOctets = a: b: c: d: e: f: {
|
||||
mac = builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 (builtins.bitOr (bit.left 8 a) b)) c)) d)) e)) f;
|
||||
mac = bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 (bit.or (bit.left 8 a) b)) c)) d)) e)) f;
|
||||
};
|
||||
in
|
||||
liftA6 fromOctets octet octet' octet' octet' octet' octet';
|
||||
|
||||
in
|
||||
{
|
||||
ipv4 = run ipv4;
|
||||
|
@ -778,14 +788,13 @@ let
|
|||
|
||||
builders =
|
||||
let
|
||||
|
||||
ipv4 =
|
||||
address:
|
||||
let
|
||||
abcd = address.ipv4;
|
||||
abc = bit.arithmeticRight 8 abcd;
|
||||
ab = bit.arithmeticRight 8 abc;
|
||||
a = bit.arithmeticRight 8 ab;
|
||||
abc = bit.right 8 abcd;
|
||||
ab = bit.right 8 abc;
|
||||
a = bit.right 8 ab;
|
||||
b = bit.mask 8 ab;
|
||||
c = bit.mask 8 abc;
|
||||
d = bit.mask 8 abcd;
|
||||
|
@ -804,18 +813,16 @@ let
|
|||
ipv6 =
|
||||
address:
|
||||
let
|
||||
|
||||
digits = "0123456789abcdef";
|
||||
|
||||
toHexString =
|
||||
n:
|
||||
let
|
||||
rest = bit.arithmeticRight 4 n;
|
||||
rest = bit.right 4 n;
|
||||
current = bit.mask 4 n;
|
||||
prefix = if rest == 0 then "" else toHexString rest;
|
||||
in
|
||||
"${prefix}${builtins.substring current 1 digits}";
|
||||
|
||||
in
|
||||
if (with address.ipv6; a == 0 && b == 0 && c == 0 && d > 65535) then
|
||||
"::${ipv4 { ipv4 = address.ipv6.d; }}"
|
||||
|
@ -823,14 +830,13 @@ let
|
|||
"::ffff:${ipv4 { ipv4 = address.ipv6.d; }}"
|
||||
else
|
||||
let
|
||||
|
||||
a = bit.arithmeticRight 16 address.ipv6.a;
|
||||
a = bit.right 16 address.ipv6.a;
|
||||
b = bit.mask 16 address.ipv6.a;
|
||||
c = bit.arithmeticRight 16 address.ipv6.b;
|
||||
c = bit.right 16 address.ipv6.b;
|
||||
d = bit.mask 16 address.ipv6.b;
|
||||
e = bit.arithmeticRight 16 address.ipv6.c;
|
||||
e = bit.right 16 address.ipv6.c;
|
||||
f = bit.mask 16 address.ipv6.c;
|
||||
g = bit.arithmeticRight 16 address.ipv6.d;
|
||||
g = bit.right 16 address.ipv6.d;
|
||||
h = bit.mask 16 address.ipv6.d;
|
||||
|
||||
hextets = [
|
||||
|
@ -919,19 +925,20 @@ let
|
|||
octet =
|
||||
n:
|
||||
let
|
||||
upper = bit.arithmeticRight 4 n;
|
||||
upper = bit.right 4 n;
|
||||
lower = bit.mask 4 n;
|
||||
in
|
||||
"${builtins.substring upper 1 digits}${builtins.substring lower 1 digits}";
|
||||
a = bit.mask 8 (bit.arithmeticRight 40 address.mac);
|
||||
b = bit.mask 8 (bit.arithmeticRight 32 address.mac);
|
||||
c = bit.mask 8 (bit.arithmeticRight 24 address.mac);
|
||||
d = bit.mask 8 (bit.arithmeticRight 16 address.mac);
|
||||
e = bit.mask 8 (bit.arithmeticRight 8 address.mac);
|
||||
f = bit.mask 8 (bit.arithmeticRight 0 address.mac);
|
||||
in
|
||||
let
|
||||
a = bit.mask 8 (bit.right 40 address.mac);
|
||||
b = bit.mask 8 (bit.right 32 address.mac);
|
||||
c = bit.mask 8 (bit.right 24 address.mac);
|
||||
d = bit.mask 8 (bit.right 16 address.mac);
|
||||
e = bit.mask 8 (bit.right 8 address.mac);
|
||||
f = bit.mask 8 (bit.right 0 address.mac);
|
||||
in
|
||||
"${octet a}:${octet b}:${octet c}:${octet d}:${octet e}:${octet f}";
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
|
@ -955,22 +962,22 @@ let
|
|||
if a ? ipv6 then
|
||||
{
|
||||
ipv6 = {
|
||||
a = builtins.bitOr a.ipv6.a b.ipv6.a;
|
||||
b = builtins.bitOr a.ipv6.b b.ipv6.b;
|
||||
c = builtins.bitOr a.ipv6.c b.ipv6.c;
|
||||
d = builtins.bitOr a.ipv6.d b.ipv6.d;
|
||||
a = bit.or a.ipv6.a b.ipv6.a;
|
||||
b = bit.or a.ipv6.b b.ipv6.b;
|
||||
c = bit.or a.ipv6.c b.ipv6.c;
|
||||
d = bit.or a.ipv6.d b.ipv6.d;
|
||||
};
|
||||
}
|
||||
else if a ? ipv4 then
|
||||
{
|
||||
ipv4 = builtins.bitOr a.ipv4 b.ipv4;
|
||||
ipv4 = bit.or a.ipv4 b.ipv4;
|
||||
}
|
||||
else if a ? mac then
|
||||
{
|
||||
mac = builtins.bitOr a.mac b.mac;
|
||||
mac = bit.or a.mac b.mac;
|
||||
}
|
||||
else
|
||||
builtins.bitOr a b;
|
||||
bit.or a b;
|
||||
|
||||
# and :: (ip | mac | integer) -> (ip | mac | integer) -> (ip | mac | integer)
|
||||
and =
|
||||
|
@ -981,22 +988,22 @@ let
|
|||
if a ? ipv6 then
|
||||
{
|
||||
ipv6 = {
|
||||
a = builtins.bitAnd a.ipv6.a b.ipv6.a;
|
||||
b = builtins.bitAnd a.ipv6.b b.ipv6.b;
|
||||
c = builtins.bitAnd a.ipv6.c b.ipv6.c;
|
||||
d = builtins.bitAnd a.ipv6.d b.ipv6.d;
|
||||
a = bit.and a.ipv6.a b.ipv6.a;
|
||||
b = bit.and a.ipv6.b b.ipv6.b;
|
||||
c = bit.and a.ipv6.c b.ipv6.c;
|
||||
d = bit.and a.ipv6.d b.ipv6.d;
|
||||
};
|
||||
}
|
||||
else if a ? ipv4 then
|
||||
{
|
||||
ipv4 = builtins.bitAnd a.ipv4 b.ipv4;
|
||||
ipv4 = bit.and a.ipv4 b.ipv4;
|
||||
}
|
||||
else if a ? mac then
|
||||
{
|
||||
mac = builtins.bitAnd a.mac b.mac;
|
||||
mac = bit.and a.mac b.mac;
|
||||
}
|
||||
else
|
||||
builtins.bitAnd a b;
|
||||
bit.and a b;
|
||||
|
||||
# not :: (ip | mac | integer) -> (ip | mac | integer)
|
||||
not =
|
||||
|
@ -1025,7 +1032,7 @@ let
|
|||
add =
|
||||
let
|
||||
split = a: {
|
||||
fst = bit.mask 32 (bit.arithmeticRight 32 a);
|
||||
fst = bit.mask 32 (bit.right 32 a);
|
||||
snd = bit.mask 32 a;
|
||||
};
|
||||
in
|
||||
|
@ -1071,10 +1078,10 @@ let
|
|||
max32 = bit.left 32 1 - 1;
|
||||
in
|
||||
if
|
||||
result.a == 0 && result.b == 0 && bit.arithmeticRight 31 result.c == 0
|
||||
|| result.a == max32 && result.b == max32 && bit.arithmeticRight 31 result.c == 1
|
||||
result.a == 0 && result.b == 0 && bit.right 31 result.c == 0
|
||||
|| result.a == max32 && result.b == max32 && bit.right 31 result.c == 1
|
||||
then
|
||||
builtins.bitOr (bit.left 32 result.c) result.d
|
||||
bit.or (bit.left 32 result.c) result.d
|
||||
else
|
||||
{
|
||||
ipv6 = result;
|
||||
|
@ -1087,15 +1094,15 @@ let
|
|||
right =
|
||||
let
|
||||
step = i: x: {
|
||||
_1 = bit.mask 32 (bit.arithRightOrLeft (i + 96) x);
|
||||
_2 = bit.mask 32 (bit.arithRightOrLeft (i + 64) x);
|
||||
_3 = bit.mask 32 (bit.arithRightOrLeft (i + 32) x);
|
||||
_4 = bit.mask 32 (bit.arithRightOrLeft i x);
|
||||
_5 = bit.mask 32 (bit.arithRightOrLeft (i - 32) x);
|
||||
_6 = bit.mask 32 (bit.arithRightOrLeft (i - 64) x);
|
||||
_7 = bit.mask 32 (bit.arithRightOrLeft (i - 96) x);
|
||||
_1 = bit.mask 32 (bit.right (i + 96) x);
|
||||
_2 = bit.mask 32 (bit.right (i + 64) x);
|
||||
_3 = bit.mask 32 (bit.right (i + 32) x);
|
||||
_4 = bit.mask 32 (bit.right i x);
|
||||
_5 = bit.mask 32 (bit.right (i - 32) x);
|
||||
_6 = bit.mask 32 (bit.right (i - 64) x);
|
||||
_7 = bit.mask 32 (bit.right (i - 96) x);
|
||||
};
|
||||
ors = builtins.foldl' builtins.bitOr 0;
|
||||
ors = builtins.foldl' bit.or 0;
|
||||
in
|
||||
i: x:
|
||||
if x ? ipv6 then
|
||||
|
@ -1135,14 +1142,14 @@ let
|
|||
}
|
||||
else if x ? ipv4 then
|
||||
{
|
||||
ipv4 = bit.mask 32 (bit.arithRightOrLeft i x.ipv4);
|
||||
ipv4 = bit.mask 32 (bit.right i x.ipv4);
|
||||
}
|
||||
else if x ? mac then
|
||||
{
|
||||
mac = bit.mask 48 (bit.arithRightOrLeft i x.mac);
|
||||
mac = bit.mask 48 (bit.right i x.mac);
|
||||
}
|
||||
else
|
||||
bit.arithRightOrLeft i x;
|
||||
bit.right i x;
|
||||
|
||||
# shadow :: integer -> (ip | mac | integer) -> (ip | mac | integer)
|
||||
shadow = n: a: and (right n (left n (coerce a (-1)))) a;
|
||||
|
@ -1150,10 +1157,7 @@ let
|
|||
# coshadow :: integer -> (ip | mac | integer) -> (ip | mac | integer)
|
||||
coshadow = n: a: and (not (right n (left n (coerce a (-1))))) a;
|
||||
|
||||
# coerce target value
|
||||
# coerce value to the type of target
|
||||
# coerce :: A -> (ip | mac | integer) -> A
|
||||
# where A :: (ip | mac | integer)
|
||||
# coerce :: (ip | mac | integer) -> (ip | mac | integer) -> (ip | mac | integer)
|
||||
coerce =
|
||||
target: value:
|
||||
if target ? ipv6 then
|
||||
|
@ -1173,16 +1177,16 @@ let
|
|||
ipv6 = {
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = bit.arithmeticRight 32 value.mac;
|
||||
c = bit.right 32 value.mac;
|
||||
d = bit.mask 32 value.mac;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
ipv6 = {
|
||||
a = bit.mask 32 (bit.arithmeticRight 96 value);
|
||||
b = bit.mask 32 (bit.arithmeticRight 64 value);
|
||||
c = bit.mask 32 (bit.arithmeticRight 32 value);
|
||||
a = bit.mask 32 (bit.right 96 value);
|
||||
b = bit.mask 32 (bit.right 64 value);
|
||||
c = bit.mask 32 (bit.right 32 value);
|
||||
d = bit.mask 32 value;
|
||||
};
|
||||
}
|
||||
|
@ -1204,7 +1208,7 @@ let
|
|||
else if target ? mac then
|
||||
if value ? ipv6 then
|
||||
{
|
||||
mac = builtins.bitOr (bit.left 32 (bit.mask 16 value.ipv6.c)) value.ipv6.d;
|
||||
mac = bit.or (bit.left 32 (bit.mask 16 value.ipv6.c)) value.ipv6.d;
|
||||
}
|
||||
else if value ? ipv4 then
|
||||
{
|
||||
|
@ -1217,17 +1221,43 @@ let
|
|||
mac = bit.mask 48 value;
|
||||
}
|
||||
else if value ? ipv6 then
|
||||
builtins.foldl' builtins.bitOr 0 [
|
||||
builtins.foldl' bit.or 0 [
|
||||
(bit.left 96 value.ipv6.a)
|
||||
(bit.left 64 value.ipv6.b)
|
||||
(bit.left 32 value.ipv6.c)
|
||||
value.ipv6.d
|
||||
]
|
||||
else if value ? ipv4 then
|
||||
value.ipv4
|
||||
else if value ? mac then
|
||||
value.mac
|
||||
else
|
||||
value.ipv4 or value.mac or value;
|
||||
value;
|
||||
};
|
||||
|
||||
implementations = {
|
||||
ip = {
|
||||
# add :: (ip | mac | integer) -> ip -> ip
|
||||
add = arithmetic.add;
|
||||
|
||||
# diff :: ip -> ip -> (ipv6 | integer)
|
||||
diff = arithmetic.diff;
|
||||
|
||||
# subtract :: (ip | mac | integer) -> ip -> ip
|
||||
subtract = arithmetic.subtract;
|
||||
};
|
||||
|
||||
mac = {
|
||||
# add :: (ip | mac | integer) -> mac -> mac
|
||||
add = arithmetic.add;
|
||||
|
||||
# diff :: mac -> mac -> (ipv6 | integer)
|
||||
diff = arithmetic.diff;
|
||||
|
||||
# subtract :: (ip | mac | integer) -> mac -> mac
|
||||
subtract = arithmetic.subtract;
|
||||
};
|
||||
|
||||
cidr = rec {
|
||||
# add :: (ip | mac | integer) -> cidr -> cidr
|
||||
add =
|
||||
|
@ -1236,7 +1266,7 @@ let
|
|||
size' = size cidr;
|
||||
in
|
||||
{
|
||||
base = arithmetic.left size' (arithmetic.add delta (arithmetic.arithRightOrLeft size' cidr.base));
|
||||
base = arithmetic.left size' (arithmetic.add delta (arithmetic.right size' cidr.base));
|
||||
inherit (cidr) length;
|
||||
};
|
||||
|
||||
|
@ -1299,7 +1329,6 @@ let
|
|||
|
||||
typechecks =
|
||||
let
|
||||
|
||||
fail =
|
||||
description: function: argument:
|
||||
builtins.throw "${function}: ${argument} parameter must be ${description}";
|
||||
|
@ -1316,7 +1345,6 @@ let
|
|||
result = parser input;
|
||||
in
|
||||
if builtins.isNull result then error else result;
|
||||
|
||||
in
|
||||
{
|
||||
int =
|
||||
|
@ -1332,9 +1360,7 @@ let
|
|||
else
|
||||
meta parsers.numeric "an integer or IPv4, IPv6 or MAC address" function argument input;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
lib = {
|
||||
inherit
|
||||
|
|
128
lib/shift.nix
128
lib/shift.nix
|
@ -1,128 +0,0 @@
|
|||
let
|
||||
# lut = [
|
||||
# 1 # 0
|
||||
# 2 # 1
|
||||
# 4 # 2
|
||||
# 8 # 3
|
||||
# 16 # 4
|
||||
# 32 # 5
|
||||
# 64 # 6
|
||||
# 128 # 7
|
||||
# 256 # 8
|
||||
# 512 # 9
|
||||
# 1024 # 10
|
||||
# 2048 # 11
|
||||
# 4096 # 12
|
||||
# 8192 # 13
|
||||
# 16384 # 14
|
||||
# 32768 # 15
|
||||
# 65536 # 16
|
||||
# 131072 # 17
|
||||
# 262144 # 18
|
||||
# 524288 # 19
|
||||
# 1048576 # 20
|
||||
# 2097152 # 21
|
||||
# 4194304 # 22
|
||||
# 8388608 # 23
|
||||
# 16777216 # 24
|
||||
# 33554432 # 25
|
||||
# 67108864 # 26
|
||||
# 134217728 # 27
|
||||
# 268435456 # 28
|
||||
# 536870912 # 29
|
||||
# 1073741824 # 30
|
||||
# 2147483648 # 31
|
||||
# 4294967296 # 32
|
||||
# 8589934592 # 33
|
||||
# 17179869184 # 34
|
||||
# 34359738368 # 35
|
||||
# 68719476736 # 36
|
||||
# 137438953472 # 37
|
||||
# 274877906944 # 38
|
||||
# 549755813888 # 39
|
||||
# 1099511627776 # 40
|
||||
# 2199023255552 # 41
|
||||
# 4398046511104 # 42
|
||||
# 8796093022208 # 43
|
||||
# 17592186044416 # 44
|
||||
# 35184372088832 # 45
|
||||
# 70368744177664 # 46
|
||||
# 140737488355328 # 47
|
||||
# 281474976710656 # 48
|
||||
# 562949953421312 # 49
|
||||
# 1125899906842624 # 50
|
||||
# 2251799813685248 # 51
|
||||
# 4503599627370496 # 52
|
||||
# 9007199254740992 # 53
|
||||
# 18014398509481984 # 54
|
||||
# 36028797018963968 # 55
|
||||
# 72057594037927936 # 56
|
||||
# 144115188075855872 # 57
|
||||
# 288230376151711744 # 58
|
||||
# 576460752303423488 # 59
|
||||
# 1152921504606846976 # 60
|
||||
# 2305843009213693952 # 61
|
||||
# 4611686018427387904 # 62
|
||||
# ];
|
||||
lut = builtins.foldl' (l: n: l ++ [ (2 * builtins.elemAt l n) ]) [ 1 ] (builtins.genList (x: x) 62);
|
||||
intmin = (-9223372036854775807) - 1;
|
||||
intmax = 9223372036854775807;
|
||||
left =
|
||||
a: b:
|
||||
if a >= 64 then
|
||||
# It's allowed to shift out all bits
|
||||
0
|
||||
else if a == 0 then
|
||||
b
|
||||
else if a < 0 then
|
||||
throw "Inverse Left Shift not supported"
|
||||
else
|
||||
let
|
||||
inv = 63 - a;
|
||||
mask = if inv == 63 then intmax else (builtins.elemAt lut inv) - 1;
|
||||
masked = builtins.bitAnd b mask;
|
||||
checker = if inv == 63 then intmin else builtins.elemAt lut inv;
|
||||
negate = (builtins.bitAnd b checker) != 0;
|
||||
mult = if a == 63 then intmin else builtins.elemAt lut a;
|
||||
result = masked * mult;
|
||||
in
|
||||
if !negate then result else intmin + result;
|
||||
logicalRight =
|
||||
a: b:
|
||||
if a >= 64 then
|
||||
0
|
||||
else if a == 0 then
|
||||
b
|
||||
else if a < 0 then
|
||||
throw "Inverse right Shift not supported"
|
||||
else
|
||||
let
|
||||
masked = builtins.bitAnd b intmax;
|
||||
negate = b < 0;
|
||||
# Split division to prevent having to divide by a negative number for
|
||||
# shifts of 63 bit
|
||||
result = masked / 2 / (builtins.elemAt lut (a - 1));
|
||||
inv = 63 - a;
|
||||
highest_bit = builtins.elemAt lut inv;
|
||||
in
|
||||
if !negate then result else result + highest_bit;
|
||||
arithmeticRight =
|
||||
a: b:
|
||||
if a >= 64 then
|
||||
if b < 0 then -1 else 0
|
||||
else if a == 0 then
|
||||
b
|
||||
else if a < 0 then
|
||||
throw "Inverse right Shift not supported"
|
||||
else
|
||||
let
|
||||
negate = b < 0;
|
||||
mask = if a == 63 then intmax else (builtins.elemAt lut a) - 1;
|
||||
round_down = negate && (builtins.bitAnd mask b != 0);
|
||||
result = b / 2 / (builtins.elemAt lut (a - 1));
|
||||
in
|
||||
if round_down then result - 1 else result;
|
||||
in
|
||||
{
|
||||
inherit left logicalRight arithmeticRight;
|
||||
}
|
|
@ -98,6 +98,7 @@ in
|
|||
'}';
|
||||
error_log syslog:server=unix:/dev/log,nohostname;
|
||||
access_log syslog:server=unix:/dev/log,nohostname json_combined;
|
||||
ssl_ecdh_curve secp384r1;
|
||||
'';
|
||||
|
||||
# Default host that rejects everything.
|
||||
|
|
|
@ -36,7 +36,7 @@ in
|
|||
flip mapAttrsToList memberWG (
|
||||
networkName: networkCfg:
|
||||
let
|
||||
assertionPrefix = "While evaluating the wireguard network ${networkName}:";
|
||||
assertionPrefix = "While evaluation the wireguard network ${networkName}:";
|
||||
hostCfg = networkCfg.hosts.${config.node.name};
|
||||
in
|
||||
[
|
||||
|
|
|
@ -23,7 +23,7 @@ in
|
|||
options = {
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
description = "The host name or IP address under which the server node is reachable from any client.";
|
||||
description = "The host name or IP addresse for reaching the server node.";
|
||||
};
|
||||
idFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
|
@ -61,9 +61,16 @@ in
|
|||
config.id =
|
||||
let
|
||||
inherit (wgConf) idFile;
|
||||
idFromFile = if (idFile == null) then null else (importJSON idFile).${name} or null;
|
||||
in
|
||||
lib.mkIf (idFromFile != null) idFromFile;
|
||||
if (idFile == null) then
|
||||
null
|
||||
else
|
||||
(
|
||||
let
|
||||
conf = importJSON idFile;
|
||||
in
|
||||
conf.${name} or null
|
||||
);
|
||||
options = {
|
||||
server = mkOption {
|
||||
default = false;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
nixt,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
[
|
||||
(import ./shift.nix { inherit pkgs nixt; })
|
||||
(import ./net.nix { inherit pkgs nixt; })
|
||||
]
|
101
tests/net.nix
101
tests/net.nix
|
@ -1,101 +0,0 @@
|
|||
{
|
||||
nixt,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (nixt.lib) block describe it;
|
||||
inherit (pkgs) lib;
|
||||
expected = {
|
||||
cidrv6 = {
|
||||
empty = {
|
||||
base = {
|
||||
ipv6 = {
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
};
|
||||
};
|
||||
length = 0;
|
||||
};
|
||||
base4 = {
|
||||
base = {
|
||||
ipv6 = {
|
||||
a = 65536;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
};
|
||||
};
|
||||
length = 4;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
block ./net.nix [
|
||||
(describe "cidrv6" [
|
||||
(it "child 1" (lib.net.cidr.child "1::/4" "0::/0"))
|
||||
(it "child 2" (lib.net.cidr.child "1::/4" "::/0"))
|
||||
(it "child 3" (!lib.net.cidr.child "::/0" "::/4"))
|
||||
(it "child 4" (lib.net.cidr.child "1100::/8" "1000::/4"))
|
||||
(it "child 5" (!lib.net.cidr.child "1100::/16" "1000::/8"))
|
||||
(it "child 6" (lib.net.cidr.child "0:1::/24" "0:1::/8"))
|
||||
|
||||
(it "typechecks 1" (lib.typechecks.cidr "" "" "::/0" == expected.cidrv6.empty))
|
||||
(it "typechecks 2" (lib.typechecks.cidr "" "" "0::/0" == expected.cidrv6.empty))
|
||||
(it "typechecks 3" (lib.typechecks.cidr "" "" "1::/4" == expected.cidrv6.empty // { length = 4; }))
|
||||
|
||||
(it "impl child" (lib.implementations.cidr.child expected.cidrv6.base4 expected.cidrv6.empty))
|
||||
|
||||
(it "cidr length 0" (lib.implementations.cidr.length expected.cidrv6.empty == 0))
|
||||
(it "cidr length 4" (lib.implementations.cidr.length expected.cidrv6.base4 == 4))
|
||||
|
||||
(it "contains 4" (
|
||||
lib.implementations.cidr.contains expected.cidrv6.base4.base expected.cidrv6.empty
|
||||
))
|
||||
|
||||
(it "host 4" (lib.implementations.cidr.host 0 expected.cidrv6.base4 == expected.cidrv6.base4.base))
|
||||
(it "host 0" (lib.implementations.cidr.host 0 expected.cidrv6.empty == expected.cidrv6.empty.base))
|
||||
|
||||
(it "make len 0" (
|
||||
lib.implementations.cidr.make 0 expected.cidrv6.base4.base == expected.cidrv6.empty
|
||||
))
|
||||
(it "make base 4 len 0 length" (
|
||||
(lib.implementations.cidr.make 0 expected.cidrv6.base4.base).length == 0
|
||||
))
|
||||
(it "make base 4 len 0 base" (
|
||||
(lib.implementations.cidr.make 0 expected.cidrv6.base4.base).base == expected.cidrv6.empty.base
|
||||
))
|
||||
])
|
||||
(describe "cidrv4" [
|
||||
(it "child 1" (lib.net.cidr.child "10.10.10.0/24" "10.0.0.0/8"))
|
||||
(it "child 2" (!lib.net.cidr.child "127.0.0.0/24" "10.0.0.0/8"))
|
||||
])
|
||||
(describe "cidr" [
|
||||
(it "host 255" (lib.net.cidr.host 255 "192.168.1.0/24" == "192.168.1.255"))
|
||||
(it "host err" ((builtins.tryEval (lib.net.cidr.host 256 "192.168.1.0/24")).success == false))
|
||||
(it "host -1" (lib.net.cidr.host (-1) "192.168.1.0/24" == "192.168.1.255"))
|
||||
(it "host -256" (lib.net.cidr.host (-256) "192.168.1.0/24" == "192.168.1.0"))
|
||||
(it "host -err" ((builtins.tryEval (lib.net.cidr.host (-257) "192.168.1.0/24")).success == false))
|
||||
(it "host ip" (lib.net.cidr.host "0.0.0.1" "192.168.1.0/24" == "192.168.1.1"))
|
||||
])
|
||||
(describe "arithmetic" [
|
||||
(it "coshadow 1" (
|
||||
(lib.arithmetic.coshadow 0 expected.cidrv6.base4.base) == expected.cidrv6.empty.base
|
||||
))
|
||||
(it "coerce 1" (
|
||||
(lib.arithmetic.coerce expected.cidrv6.base4.base (-1)) == {
|
||||
ipv6 = {
|
||||
a = 4294967295;
|
||||
b = 4294967295;
|
||||
c = 4294967295;
|
||||
d = 4294967295;
|
||||
};
|
||||
}
|
||||
))
|
||||
])
|
||||
(describe "bit" [
|
||||
(it "mask 32 " ((lib.bit.mask 32 (-1)) == 4294967295))
|
||||
])
|
||||
]
|
399
tests/shift.nix
399
tests/shift.nix
|
@ -1,399 +0,0 @@
|
|||
{
|
||||
nixt,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (nixt.lib) block describe it;
|
||||
inherit (pkgs.lib.bit) left logicalRight arithmeticRight;
|
||||
in
|
||||
block ./shift.nix [
|
||||
(describe "" [
|
||||
(it "left shift 31065 << 63" (left 63 31065 == -9223372036854775807 - 1))
|
||||
(it "negative left shift 31065 << 63" (left 63 (-31065) == -9223372036854775807 - 1))
|
||||
(it "logical right shift 31065 >> 63" (logicalRight 63 31065 == 0))
|
||||
(it "negative logical right shift 31065 >> 63" (logicalRight 63 (-31065) == 1))
|
||||
(it "arithmetic right shift 31065 >> 63" (arithmeticRight 63 31065 == 0))
|
||||
(it "negative arithmetic right shift 31065 >> 63" (arithmeticRight 63 (-31065) == -1))
|
||||
(it "left shift 25624 << 62" (left 62 25624 == 0))
|
||||
(it "negative left shift 25624 << 62" (left 62 (-25624) == 0))
|
||||
(it "logical right shift 25624 >> 62" (logicalRight 62 25624 == 0))
|
||||
(it "negative logical right shift 25624 >> 62" (logicalRight 62 (-25624) == 3))
|
||||
(it "arithmetic right shift 25624 >> 62" (arithmeticRight 62 25624 == 0))
|
||||
(it "negative arithmetic right shift 25624 >> 62" (arithmeticRight 62 (-25624) == -1))
|
||||
(it "left shift 308 << 61" (left 61 308 == -9223372036854775807 - 1))
|
||||
(it "negative left shift 308 << 61" (left 61 (-308) == -9223372036854775807 - 1))
|
||||
(it "logical right shift 308 >> 61" (logicalRight 61 308 == 0))
|
||||
(it "negative logical right shift 308 >> 61" (logicalRight 61 (-308) == 7))
|
||||
(it "arithmetic right shift 308 >> 61" (arithmeticRight 61 308 == 0))
|
||||
(it "negative arithmetic right shift 308 >> 61" (arithmeticRight 61 (-308) == -1))
|
||||
(it "left shift 16712 << 60" (left 60 16712 == -9223372036854775807 - 1))
|
||||
(it "negative left shift 16712 << 60" (left 60 (-16712) == -9223372036854775807 - 1))
|
||||
(it "logical right shift 16712 >> 60" (logicalRight 60 16712 == 0))
|
||||
(it "negative logical right shift 16712 >> 60" (logicalRight 60 (-16712) == 15))
|
||||
(it "arithmetic right shift 16712 >> 60" (arithmeticRight 60 16712 == 0))
|
||||
(it "negative arithmetic right shift 16712 >> 60" (arithmeticRight 60 (-16712) == -1))
|
||||
(it "left shift 5852 << 59" (left 59 5852 == -2305843009213693952))
|
||||
(it "negative left shift 5852 << 59" (left 59 (-5852) == 2305843009213693952))
|
||||
(it "logical right shift 5852 >> 59" (logicalRight 59 5852 == 0))
|
||||
(it "negative logical right shift 5852 >> 59" (logicalRight 59 (-5852) == 31))
|
||||
(it "arithmetic right shift 5852 >> 59" (arithmeticRight 59 5852 == 0))
|
||||
(it "negative arithmetic right shift 5852 >> 59" (arithmeticRight 59 (-5852) == -1))
|
||||
(it "left shift 389 << 58" (left 58 389 == 1441151880758558720))
|
||||
(it "negative left shift 389 << 58" (left 58 (-389) == -1441151880758558720))
|
||||
(it "logical right shift 389 >> 58" (logicalRight 58 389 == 0))
|
||||
(it "negative logical right shift 389 >> 58" (logicalRight 58 (-389) == 63))
|
||||
(it "arithmetic right shift 389 >> 58" (arithmeticRight 58 389 == 0))
|
||||
(it "negative arithmetic right shift 389 >> 58" (arithmeticRight 58 (-389) == -1))
|
||||
(it "left shift 13663 << 57" (left 57 13663 == -4755801206503243776))
|
||||
(it "negative left shift 13663 << 57" (left 57 (-13663) == 4755801206503243776))
|
||||
(it "logical right shift 13663 >> 57" (logicalRight 57 13663 == 0))
|
||||
(it "negative logical right shift 13663 >> 57" (logicalRight 57 (-13663) == 127))
|
||||
(it "arithmetic right shift 13663 >> 57" (arithmeticRight 57 13663 == 0))
|
||||
(it "negative arithmetic right shift 13663 >> 57" (arithmeticRight 57 (-13663) == -1))
|
||||
(it "left shift 15349 << 56" (left 56 15349 == -792633534417207296))
|
||||
(it "negative left shift 15349 << 56" (left 56 (-15349) == 792633534417207296))
|
||||
(it "logical right shift 15349 >> 56" (logicalRight 56 15349 == 0))
|
||||
(it "negative logical right shift 15349 >> 56" (logicalRight 56 (-15349) == 255))
|
||||
(it "arithmetic right shift 15349 >> 56" (arithmeticRight 56 15349 == 0))
|
||||
(it "negative arithmetic right shift 15349 >> 56" (arithmeticRight 56 (-15349) == -1))
|
||||
(it "left shift 25817 << 55" (left 55 25817 == 7818248953115181056))
|
||||
(it "negative left shift 25817 << 55" (left 55 (-25817) == -7818248953115181056))
|
||||
(it "logical right shift 25817 >> 55" (logicalRight 55 25817 == 0))
|
||||
(it "negative logical right shift 25817 >> 55" (logicalRight 55 (-25817) == 511))
|
||||
(it "arithmetic right shift 25817 >> 55" (arithmeticRight 55 25817 == 0))
|
||||
(it "negative arithmetic right shift 25817 >> 55" (arithmeticRight 55 (-25817) == -1))
|
||||
(it "left shift 896 << 54" (left 54 896 == -2305843009213693952))
|
||||
(it "negative left shift 896 << 54" (left 54 (-896) == 2305843009213693952))
|
||||
(it "logical right shift 896 >> 54" (logicalRight 54 896 == 0))
|
||||
(it "negative logical right shift 896 >> 54" (logicalRight 54 (-896) == 1023))
|
||||
(it "arithmetic right shift 896 >> 54" (arithmeticRight 54 896 == 0))
|
||||
(it "negative arithmetic right shift 896 >> 54" (arithmeticRight 54 (-896) == -1))
|
||||
(it "left shift 14592 << 53" (left 53 14592 == 2305843009213693952))
|
||||
(it "negative left shift 14592 << 53" (left 53 (-14592) == -2305843009213693952))
|
||||
(it "logical right shift 14592 >> 53" (logicalRight 53 14592 == 0))
|
||||
(it "negative logical right shift 14592 >> 53" (logicalRight 53 (-14592) == 2047))
|
||||
(it "arithmetic right shift 14592 >> 53" (arithmeticRight 53 14592 == 0))
|
||||
(it "negative arithmetic right shift 14592 >> 53" (arithmeticRight 53 (-14592) == -1))
|
||||
(it "left shift 8533 << 52" (left 52 8533 == 1535727472933339136))
|
||||
(it "negative left shift 8533 << 52" (left 52 (-8533) == -1535727472933339136))
|
||||
(it "logical right shift 8533 >> 52" (logicalRight 52 8533 == 0))
|
||||
(it "negative logical right shift 8533 >> 52" (logicalRight 52 (-8533) == 4095))
|
||||
(it "arithmetic right shift 8533 >> 52" (arithmeticRight 52 8533 == 0))
|
||||
(it "negative arithmetic right shift 8533 >> 52" (arithmeticRight 52 (-8533) == -1))
|
||||
(it "left shift 30180 << 51" (left 51 30180 == -5827657917817421824))
|
||||
(it "negative left shift 30180 << 51" (left 51 (-30180) == 5827657917817421824))
|
||||
(it "logical right shift 30180 >> 51" (logicalRight 51 30180 == 0))
|
||||
(it "negative logical right shift 30180 >> 51" (logicalRight 51 (-30180) == 8191))
|
||||
(it "arithmetic right shift 30180 >> 51" (arithmeticRight 51 30180 == 0))
|
||||
(it "negative arithmetic right shift 30180 >> 51" (arithmeticRight 51 (-30180) == -1))
|
||||
(it "left shift 24903 << 50" (left 50 24903 == -8855202767317237760))
|
||||
(it "negative left shift 24903 << 50" (left 50 (-24903) == 8855202767317237760))
|
||||
(it "logical right shift 24903 >> 50" (logicalRight 50 24903 == 0))
|
||||
(it "negative logical right shift 24903 >> 50" (logicalRight 50 (-24903) == 16383))
|
||||
(it "arithmetic right shift 24903 >> 50" (arithmeticRight 50 24903 == 0))
|
||||
(it "negative arithmetic right shift 24903 >> 50" (arithmeticRight 50 (-24903) == -1))
|
||||
(it "left shift 14440 << 49" (left 49 14440 == 8128997327403745280))
|
||||
(it "negative left shift 14440 << 49" (left 49 (-14440) == -8128997327403745280))
|
||||
(it "logical right shift 14440 >> 49" (logicalRight 49 14440 == 0))
|
||||
(it "negative logical right shift 14440 >> 49" (logicalRight 49 (-14440) == 32767))
|
||||
(it "arithmetic right shift 14440 >> 49" (arithmeticRight 49 14440 == 0))
|
||||
(it "negative arithmetic right shift 14440 >> 49" (arithmeticRight 49 (-14440) == -1))
|
||||
(it "left shift 7398 << 48" (left 48 7398 == 2082351877705433088))
|
||||
(it "negative left shift 7398 << 48" (left 48 (-7398) == -2082351877705433088))
|
||||
(it "logical right shift 7398 >> 48" (logicalRight 48 7398 == 0))
|
||||
(it "negative logical right shift 7398 >> 48" (logicalRight 48 (-7398) == 65535))
|
||||
(it "arithmetic right shift 7398 >> 48" (arithmeticRight 48 7398 == 0))
|
||||
(it "negative arithmetic right shift 7398 >> 48" (arithmeticRight 48 (-7398) == -1))
|
||||
(it "left shift 10215 << 47" (left 47 10215 == 1437633443549675520))
|
||||
(it "negative left shift 10215 << 47" (left 47 (-10215) == -1437633443549675520))
|
||||
(it "logical right shift 10215 >> 47" (logicalRight 47 10215 == 0))
|
||||
(it "negative logical right shift 10215 >> 47" (logicalRight 47 (-10215) == 131071))
|
||||
(it "arithmetic right shift 10215 >> 47" (arithmeticRight 47 10215 == 0))
|
||||
(it "negative arithmetic right shift 10215 >> 47" (arithmeticRight 47 (-10215) == -1))
|
||||
(it "left shift 10172 << 46" (left 46 10172 == 715790865775198208))
|
||||
(it "negative left shift 10172 << 46" (left 46 (-10172) == -715790865775198208))
|
||||
(it "logical right shift 10172 >> 46" (logicalRight 46 10172 == 0))
|
||||
(it "negative logical right shift 10172 >> 46" (logicalRight 46 (-10172) == 262143))
|
||||
(it "arithmetic right shift 10172 >> 46" (arithmeticRight 46 10172 == 0))
|
||||
(it "negative arithmetic right shift 10172 >> 46" (arithmeticRight 46 (-10172) == -1))
|
||||
(it "left shift 15671 << 45" (left 45 15671 == 551374295004086272))
|
||||
(it "negative left shift 15671 << 45" (left 45 (-15671) == -551374295004086272))
|
||||
(it "logical right shift 15671 >> 45" (logicalRight 45 15671 == 0))
|
||||
(it "negative logical right shift 15671 >> 45" (logicalRight 45 (-15671) == 524287))
|
||||
(it "arithmetic right shift 15671 >> 45" (arithmeticRight 45 15671 == 0))
|
||||
(it "negative arithmetic right shift 15671 >> 45" (arithmeticRight 45 (-15671) == -1))
|
||||
(it "left shift 22286 << 44" (left 44 22286 == 392059458185854976))
|
||||
(it "negative left shift 22286 << 44" (left 44 (-22286) == -392059458185854976))
|
||||
(it "logical right shift 22286 >> 44" (logicalRight 44 22286 == 0))
|
||||
(it "negative logical right shift 22286 >> 44" (logicalRight 44 (-22286) == 1048575))
|
||||
(it "arithmetic right shift 22286 >> 44" (arithmeticRight 44 22286 == 0))
|
||||
(it "negative arithmetic right shift 22286 >> 44" (arithmeticRight 44 (-22286) == -1))
|
||||
(it "left shift 29742 << 43" (left 43 29742 == 261613398666510336))
|
||||
(it "negative left shift 29742 << 43" (left 43 (-29742) == -261613398666510336))
|
||||
(it "logical right shift 29742 >> 43" (logicalRight 43 29742 == 0))
|
||||
(it "negative logical right shift 29742 >> 43" (logicalRight 43 (-29742) == 2097151))
|
||||
(it "arithmetic right shift 29742 >> 43" (arithmeticRight 43 29742 == 0))
|
||||
(it "negative arithmetic right shift 29742 >> 43" (arithmeticRight 43 (-29742) == -1))
|
||||
(it "left shift 13223 << 42" (left 42 13223 == 58155369016328192))
|
||||
(it "negative left shift 13223 << 42" (left 42 (-13223) == -58155369016328192))
|
||||
(it "logical right shift 13223 >> 42" (logicalRight 42 13223 == 0))
|
||||
(it "negative logical right shift 13223 >> 42" (logicalRight 42 (-13223) == 4194303))
|
||||
(it "arithmetic right shift 13223 >> 42" (arithmeticRight 42 13223 == 0))
|
||||
(it "negative arithmetic right shift 13223 >> 42" (arithmeticRight 42 (-13223) == -1))
|
||||
(it "left shift 27362 << 41" (left 41 27362 == 60169674318413824))
|
||||
(it "negative left shift 27362 << 41" (left 41 (-27362) == -60169674318413824))
|
||||
(it "logical right shift 27362 >> 41" (logicalRight 41 27362 == 0))
|
||||
(it "negative logical right shift 27362 >> 41" (logicalRight 41 (-27362) == 8388607))
|
||||
(it "arithmetic right shift 27362 >> 41" (arithmeticRight 41 27362 == 0))
|
||||
(it "negative arithmetic right shift 27362 >> 41" (arithmeticRight 41 (-27362) == -1))
|
||||
(it "left shift 9358 << 40" (left 40 9358 == 10289229812727808))
|
||||
(it "negative left shift 9358 << 40" (left 40 (-9358) == -10289229812727808))
|
||||
(it "logical right shift 9358 >> 40" (logicalRight 40 9358 == 0))
|
||||
(it "negative logical right shift 9358 >> 40" (logicalRight 40 (-9358) == 16777215))
|
||||
(it "arithmetic right shift 9358 >> 40" (arithmeticRight 40 9358 == 0))
|
||||
(it "negative arithmetic right shift 9358 >> 40" (arithmeticRight 40 (-9358) == -1))
|
||||
(it "left shift 11691 << 39" (left 39 11691 == 6427195220164608))
|
||||
(it "negative left shift 11691 << 39" (left 39 (-11691) == -6427195220164608))
|
||||
(it "logical right shift 11691 >> 39" (logicalRight 39 11691 == 0))
|
||||
(it "negative logical right shift 11691 >> 39" (logicalRight 39 (-11691) == 33554431))
|
||||
(it "arithmetic right shift 11691 >> 39" (arithmeticRight 39 11691 == 0))
|
||||
(it "negative arithmetic right shift 11691 >> 39" (arithmeticRight 39 (-11691) == -1))
|
||||
(it "left shift 18608 << 38" (left 38 18608 == 5114928092413952))
|
||||
(it "negative left shift 18608 << 38" (left 38 (-18608) == -5114928092413952))
|
||||
(it "logical right shift 18608 >> 38" (logicalRight 38 18608 == 0))
|
||||
(it "negative logical right shift 18608 >> 38" (logicalRight 38 (-18608) == 67108863))
|
||||
(it "arithmetic right shift 18608 >> 38" (arithmeticRight 38 18608 == 0))
|
||||
(it "negative arithmetic right shift 18608 >> 38" (arithmeticRight 38 (-18608) == -1))
|
||||
(it "left shift 30802 << 37" (left 37 30802 == 4233394644844544))
|
||||
(it "negative left shift 30802 << 37" (left 37 (-30802) == -4233394644844544))
|
||||
(it "logical right shift 30802 >> 37" (logicalRight 37 30802 == 0))
|
||||
(it "negative logical right shift 30802 >> 37" (logicalRight 37 (-30802) == 134217727))
|
||||
(it "arithmetic right shift 30802 >> 37" (arithmeticRight 37 30802 == 0))
|
||||
(it "negative arithmetic right shift 30802 >> 37" (arithmeticRight 37 (-30802) == -1))
|
||||
(it "left shift 25321 << 36" (left 36 25321 == 1740045870432256))
|
||||
(it "negative left shift 25321 << 36" (left 36 (-25321) == -1740045870432256))
|
||||
(it "logical right shift 25321 >> 36" (logicalRight 36 25321 == 0))
|
||||
(it "negative logical right shift 25321 >> 36" (logicalRight 36 (-25321) == 268435455))
|
||||
(it "arithmetic right shift 25321 >> 36" (arithmeticRight 36 25321 == 0))
|
||||
(it "negative arithmetic right shift 25321 >> 36" (arithmeticRight 36 (-25321) == -1))
|
||||
(it "left shift 21777 << 35" (left 35 21777 == 748252022439936))
|
||||
(it "negative left shift 21777 << 35" (left 35 (-21777) == -748252022439936))
|
||||
(it "logical right shift 21777 >> 35" (logicalRight 35 21777 == 0))
|
||||
(it "negative logical right shift 21777 >> 35" (logicalRight 35 (-21777) == 536870911))
|
||||
(it "arithmetic right shift 21777 >> 35" (arithmeticRight 35 21777 == 0))
|
||||
(it "negative arithmetic right shift 21777 >> 35" (arithmeticRight 35 (-21777) == -1))
|
||||
(it "left shift 19037 << 34" (left 34 19037 == 327053169655808))
|
||||
(it "negative left shift 19037 << 34" (left 34 (-19037) == -327053169655808))
|
||||
(it "logical right shift 19037 >> 34" (logicalRight 34 19037 == 0))
|
||||
(it "negative logical right shift 19037 >> 34" (logicalRight 34 (-19037) == 1073741823))
|
||||
(it "arithmetic right shift 19037 >> 34" (arithmeticRight 34 19037 == 0))
|
||||
(it "negative arithmetic right shift 19037 >> 34" (arithmeticRight 34 (-19037) == -1))
|
||||
(it "left shift 23041 << 33" (left 33 23041 == 197920682934272))
|
||||
(it "negative left shift 23041 << 33" (left 33 (-23041) == -197920682934272))
|
||||
(it "logical right shift 23041 >> 33" (logicalRight 33 23041 == 0))
|
||||
(it "negative logical right shift 23041 >> 33" (logicalRight 33 (-23041) == 2147483647))
|
||||
(it "arithmetic right shift 23041 >> 33" (arithmeticRight 33 23041 == 0))
|
||||
(it "negative arithmetic right shift 23041 >> 33" (arithmeticRight 33 (-23041) == -1))
|
||||
(it "left shift 13483 << 32" (left 32 13483 == 57909044051968))
|
||||
(it "negative left shift 13483 << 32" (left 32 (-13483) == -57909044051968))
|
||||
(it "logical right shift 13483 >> 32" (logicalRight 32 13483 == 0))
|
||||
(it "negative logical right shift 13483 >> 32" (logicalRight 32 (-13483) == 4294967295))
|
||||
(it "arithmetic right shift 13483 >> 32" (arithmeticRight 32 13483 == 0))
|
||||
(it "negative arithmetic right shift 13483 >> 32" (arithmeticRight 32 (-13483) == -1))
|
||||
(it "left shift 12790 << 31" (left 31 12790 == 27466315857920))
|
||||
(it "negative left shift 12790 << 31" (left 31 (-12790) == -27466315857920))
|
||||
(it "logical right shift 12790 >> 31" (logicalRight 31 12790 == 0))
|
||||
(it "negative logical right shift 12790 >> 31" (logicalRight 31 (-12790) == 8589934591))
|
||||
(it "arithmetic right shift 12790 >> 31" (arithmeticRight 31 12790 == 0))
|
||||
(it "negative arithmetic right shift 12790 >> 31" (arithmeticRight 31 (-12790) == -1))
|
||||
(it "left shift 29648 << 30" (left 30 29648 == 31834297597952))
|
||||
(it "negative left shift 29648 << 30" (left 30 (-29648) == -31834297597952))
|
||||
(it "logical right shift 29648 >> 30" (logicalRight 30 29648 == 0))
|
||||
(it "negative logical right shift 29648 >> 30" (logicalRight 30 (-29648) == 17179869183))
|
||||
(it "arithmetic right shift 29648 >> 30" (arithmeticRight 30 29648 == 0))
|
||||
(it "negative arithmetic right shift 29648 >> 30" (arithmeticRight 30 (-29648) == -1))
|
||||
(it "left shift 31723 << 29" (left 29 31723 == 17031155941376))
|
||||
(it "negative left shift 31723 << 29" (left 29 (-31723) == -17031155941376))
|
||||
(it "logical right shift 31723 >> 29" (logicalRight 29 31723 == 0))
|
||||
(it "negative logical right shift 31723 >> 29" (logicalRight 29 (-31723) == 34359738367))
|
||||
(it "arithmetic right shift 31723 >> 29" (arithmeticRight 29 31723 == 0))
|
||||
(it "negative arithmetic right shift 31723 >> 29" (arithmeticRight 29 (-31723) == -1))
|
||||
(it "left shift 429 << 28" (left 28 429 == 115158810624))
|
||||
(it "negative left shift 429 << 28" (left 28 (-429) == -115158810624))
|
||||
(it "logical right shift 429 >> 28" (logicalRight 28 429 == 0))
|
||||
(it "negative logical right shift 429 >> 28" (logicalRight 28 (-429) == 68719476735))
|
||||
(it "arithmetic right shift 429 >> 28" (arithmeticRight 28 429 == 0))
|
||||
(it "negative arithmetic right shift 429 >> 28" (arithmeticRight 28 (-429) == -1))
|
||||
(it "left shift 3138 << 27" (left 27 3138 == 421175230464))
|
||||
(it "negative left shift 3138 << 27" (left 27 (-3138) == -421175230464))
|
||||
(it "logical right shift 3138 >> 27" (logicalRight 27 3138 == 0))
|
||||
(it "negative logical right shift 3138 >> 27" (logicalRight 27 (-3138) == 137438953471))
|
||||
(it "arithmetic right shift 3138 >> 27" (arithmeticRight 27 3138 == 0))
|
||||
(it "negative arithmetic right shift 3138 >> 27" (arithmeticRight 27 (-3138) == -1))
|
||||
(it "left shift 20136 << 26" (left 26 20136 == 1351304085504))
|
||||
(it "negative left shift 20136 << 26" (left 26 (-20136) == -1351304085504))
|
||||
(it "logical right shift 20136 >> 26" (logicalRight 26 20136 == 0))
|
||||
(it "negative logical right shift 20136 >> 26" (logicalRight 26 (-20136) == 274877906943))
|
||||
(it "arithmetic right shift 20136 >> 26" (arithmeticRight 26 20136 == 0))
|
||||
(it "negative arithmetic right shift 20136 >> 26" (arithmeticRight 26 (-20136) == -1))
|
||||
(it "left shift 27841 << 25" (left 25 27841 == 934188941312))
|
||||
(it "negative left shift 27841 << 25" (left 25 (-27841) == -934188941312))
|
||||
(it "logical right shift 27841 >> 25" (logicalRight 25 27841 == 0))
|
||||
(it "negative logical right shift 27841 >> 25" (logicalRight 25 (-27841) == 549755813887))
|
||||
(it "arithmetic right shift 27841 >> 25" (arithmeticRight 25 27841 == 0))
|
||||
(it "negative arithmetic right shift 27841 >> 25" (arithmeticRight 25 (-27841) == -1))
|
||||
(it "left shift 23965 << 24" (left 24 23965 == 402065981440))
|
||||
(it "negative left shift 23965 << 24" (left 24 (-23965) == -402065981440))
|
||||
(it "logical right shift 23965 >> 24" (logicalRight 24 23965 == 0))
|
||||
(it "negative logical right shift 23965 >> 24" (logicalRight 24 (-23965) == 1099511627775))
|
||||
(it "arithmetic right shift 23965 >> 24" (arithmeticRight 24 23965 == 0))
|
||||
(it "negative arithmetic right shift 23965 >> 24" (arithmeticRight 24 (-23965) == -1))
|
||||
(it "left shift 9647 << 23" (left 23 9647 == 80924901376))
|
||||
(it "negative left shift 9647 << 23" (left 23 (-9647) == -80924901376))
|
||||
(it "logical right shift 9647 >> 23" (logicalRight 23 9647 == 0))
|
||||
(it "negative logical right shift 9647 >> 23" (logicalRight 23 (-9647) == 2199023255551))
|
||||
(it "arithmetic right shift 9647 >> 23" (arithmeticRight 23 9647 == 0))
|
||||
(it "negative arithmetic right shift 9647 >> 23" (arithmeticRight 23 (-9647) == -1))
|
||||
(it "left shift 13329 << 22" (left 22 13329 == 55905878016))
|
||||
(it "negative left shift 13329 << 22" (left 22 (-13329) == -55905878016))
|
||||
(it "logical right shift 13329 >> 22" (logicalRight 22 13329 == 0))
|
||||
(it "negative logical right shift 13329 >> 22" (logicalRight 22 (-13329) == 4398046511103))
|
||||
(it "arithmetic right shift 13329 >> 22" (arithmeticRight 22 13329 == 0))
|
||||
(it "negative arithmetic right shift 13329 >> 22" (arithmeticRight 22 (-13329) == -1))
|
||||
(it "left shift 32694 << 21" (left 21 32694 == 68564287488))
|
||||
(it "negative left shift 32694 << 21" (left 21 (-32694) == -68564287488))
|
||||
(it "logical right shift 32694 >> 21" (logicalRight 21 32694 == 0))
|
||||
(it "negative logical right shift 32694 >> 21" (logicalRight 21 (-32694) == 8796093022207))
|
||||
(it "arithmetic right shift 32694 >> 21" (arithmeticRight 21 32694 == 0))
|
||||
(it "negative arithmetic right shift 32694 >> 21" (arithmeticRight 21 (-32694) == -1))
|
||||
(it "left shift 17805 << 20" (left 20 17805 == 18669895680))
|
||||
(it "negative left shift 17805 << 20" (left 20 (-17805) == -18669895680))
|
||||
(it "logical right shift 17805 >> 20" (logicalRight 20 17805 == 0))
|
||||
(it "negative logical right shift 17805 >> 20" (logicalRight 20 (-17805) == 17592186044415))
|
||||
(it "arithmetic right shift 17805 >> 20" (arithmeticRight 20 17805 == 0))
|
||||
(it "negative arithmetic right shift 17805 >> 20" (arithmeticRight 20 (-17805) == -1))
|
||||
(it "left shift 32292 << 19" (left 19 32292 == 16930308096))
|
||||
(it "negative left shift 32292 << 19" (left 19 (-32292) == -16930308096))
|
||||
(it "logical right shift 32292 >> 19" (logicalRight 19 32292 == 0))
|
||||
(it "negative logical right shift 32292 >> 19" (logicalRight 19 (-32292) == 35184372088831))
|
||||
(it "arithmetic right shift 32292 >> 19" (arithmeticRight 19 32292 == 0))
|
||||
(it "negative arithmetic right shift 32292 >> 19" (arithmeticRight 19 (-32292) == -1))
|
||||
(it "left shift 16841 << 18" (left 18 16841 == 4414767104))
|
||||
(it "negative left shift 16841 << 18" (left 18 (-16841) == -4414767104))
|
||||
(it "logical right shift 16841 >> 18" (logicalRight 18 16841 == 0))
|
||||
(it "negative logical right shift 16841 >> 18" (logicalRight 18 (-16841) == 70368744177663))
|
||||
(it "arithmetic right shift 16841 >> 18" (arithmeticRight 18 16841 == 0))
|
||||
(it "negative arithmetic right shift 16841 >> 18" (arithmeticRight 18 (-16841) == -1))
|
||||
(it "left shift 18798 << 17" (left 17 18798 == 2463891456))
|
||||
(it "negative left shift 18798 << 17" (left 17 (-18798) == -2463891456))
|
||||
(it "logical right shift 18798 >> 17" (logicalRight 17 18798 == 0))
|
||||
(it "negative logical right shift 18798 >> 17" (logicalRight 17 (-18798) == 140737488355327))
|
||||
(it "arithmetic right shift 18798 >> 17" (arithmeticRight 17 18798 == 0))
|
||||
(it "negative arithmetic right shift 18798 >> 17" (arithmeticRight 17 (-18798) == -1))
|
||||
(it "left shift 2511 << 16" (left 16 2511 == 164560896))
|
||||
(it "negative left shift 2511 << 16" (left 16 (-2511) == -164560896))
|
||||
(it "logical right shift 2511 >> 16" (logicalRight 16 2511 == 0))
|
||||
(it "negative logical right shift 2511 >> 16" (logicalRight 16 (-2511) == 281474976710655))
|
||||
(it "arithmetic right shift 2511 >> 16" (arithmeticRight 16 2511 == 0))
|
||||
(it "negative arithmetic right shift 2511 >> 16" (arithmeticRight 16 (-2511) == -1))
|
||||
(it "left shift 933 << 15" (left 15 933 == 30572544))
|
||||
(it "negative left shift 933 << 15" (left 15 (-933) == -30572544))
|
||||
(it "logical right shift 933 >> 15" (logicalRight 15 933 == 0))
|
||||
(it "negative logical right shift 933 >> 15" (logicalRight 15 (-933) == 562949953421311))
|
||||
(it "arithmetic right shift 933 >> 15" (arithmeticRight 15 933 == 0))
|
||||
(it "negative arithmetic right shift 933 >> 15" (arithmeticRight 15 (-933) == -1))
|
||||
(it "left shift 26861 << 14" (left 14 26861 == 440090624))
|
||||
(it "negative left shift 26861 << 14" (left 14 (-26861) == -440090624))
|
||||
(it "logical right shift 26861 >> 14" (logicalRight 14 26861 == 1))
|
||||
(it "negative logical right shift 26861 >> 14" (logicalRight 14 (-26861) == 1125899906842622))
|
||||
(it "arithmetic right shift 26861 >> 14" (arithmeticRight 14 26861 == 1))
|
||||
(it "negative arithmetic right shift 26861 >> 14" (arithmeticRight 14 (-26861) == -2))
|
||||
(it "left shift 13766 << 13" (left 13 13766 == 112771072))
|
||||
(it "negative left shift 13766 << 13" (left 13 (-13766) == -112771072))
|
||||
(it "logical right shift 13766 >> 13" (logicalRight 13 13766 == 1))
|
||||
(it "negative logical right shift 13766 >> 13" (logicalRight 13 (-13766) == 2251799813685246))
|
||||
(it "arithmetic right shift 13766 >> 13" (arithmeticRight 13 13766 == 1))
|
||||
(it "negative arithmetic right shift 13766 >> 13" (arithmeticRight 13 (-13766) == -2))
|
||||
(it "left shift 21344 << 12" (left 12 21344 == 87425024))
|
||||
(it "negative left shift 21344 << 12" (left 12 (-21344) == -87425024))
|
||||
(it "logical right shift 21344 >> 12" (logicalRight 12 21344 == 5))
|
||||
(it "negative logical right shift 21344 >> 12" (logicalRight 12 (-21344) == 4503599627370490))
|
||||
(it "arithmetic right shift 21344 >> 12" (arithmeticRight 12 21344 == 5))
|
||||
(it "negative arithmetic right shift 21344 >> 12" (arithmeticRight 12 (-21344) == -6))
|
||||
(it "left shift 8246 << 11" (left 11 8246 == 16887808))
|
||||
(it "negative left shift 8246 << 11" (left 11 (-8246) == -16887808))
|
||||
(it "logical right shift 8246 >> 11" (logicalRight 11 8246 == 4))
|
||||
(it "negative logical right shift 8246 >> 11" (logicalRight 11 (-8246) == 9007199254740987))
|
||||
(it "arithmetic right shift 8246 >> 11" (arithmeticRight 11 8246 == 4))
|
||||
(it "negative arithmetic right shift 8246 >> 11" (arithmeticRight 11 (-8246) == -5))
|
||||
(it "left shift 18044 << 10" (left 10 18044 == 18477056))
|
||||
(it "negative left shift 18044 << 10" (left 10 (-18044) == -18477056))
|
||||
(it "logical right shift 18044 >> 10" (logicalRight 10 18044 == 17))
|
||||
(it "negative logical right shift 18044 >> 10" (logicalRight 10 (-18044) == 18014398509481966))
|
||||
(it "arithmetic right shift 18044 >> 10" (arithmeticRight 10 18044 == 17))
|
||||
(it "negative arithmetic right shift 18044 >> 10" (arithmeticRight 10 (-18044) == -18))
|
||||
(it "left shift 11554 << 9" (left 9 11554 == 5915648))
|
||||
(it "negative left shift 11554 << 9" (left 9 (-11554) == -5915648))
|
||||
(it "logical right shift 11554 >> 9" (logicalRight 9 11554 == 22))
|
||||
(it "negative logical right shift 11554 >> 9" (logicalRight 9 (-11554) == 36028797018963945))
|
||||
(it "arithmetic right shift 11554 >> 9" (arithmeticRight 9 11554 == 22))
|
||||
(it "negative arithmetic right shift 11554 >> 9" (arithmeticRight 9 (-11554) == -23))
|
||||
(it "left shift 19651 << 8" (left 8 19651 == 5030656))
|
||||
(it "negative left shift 19651 << 8" (left 8 (-19651) == -5030656))
|
||||
(it "logical right shift 19651 >> 8" (logicalRight 8 19651 == 76))
|
||||
(it "negative logical right shift 19651 >> 8" (logicalRight 8 (-19651) == 72057594037927859))
|
||||
(it "arithmetic right shift 19651 >> 8" (arithmeticRight 8 19651 == 76))
|
||||
(it "negative arithmetic right shift 19651 >> 8" (arithmeticRight 8 (-19651) == -77))
|
||||
(it "left shift 32588 << 7" (left 7 32588 == 4171264))
|
||||
(it "negative left shift 32588 << 7" (left 7 (-32588) == -4171264))
|
||||
(it "logical right shift 32588 >> 7" (logicalRight 7 32588 == 254))
|
||||
(it "negative logical right shift 32588 >> 7" (logicalRight 7 (-32588) == 144115188075855617))
|
||||
(it "arithmetic right shift 32588 >> 7" (arithmeticRight 7 32588 == 254))
|
||||
(it "negative arithmetic right shift 32588 >> 7" (arithmeticRight 7 (-32588) == -255))
|
||||
(it "left shift 23333 << 6" (left 6 23333 == 1493312))
|
||||
(it "negative left shift 23333 << 6" (left 6 (-23333) == -1493312))
|
||||
(it "logical right shift 23333 >> 6" (logicalRight 6 23333 == 364))
|
||||
(it "negative logical right shift 23333 >> 6" (logicalRight 6 (-23333) == 288230376151711379))
|
||||
(it "arithmetic right shift 23333 >> 6" (arithmeticRight 6 23333 == 364))
|
||||
(it "negative arithmetic right shift 23333 >> 6" (arithmeticRight 6 (-23333) == -365))
|
||||
(it "left shift 13058 << 5" (left 5 13058 == 417856))
|
||||
(it "negative left shift 13058 << 5" (left 5 (-13058) == -417856))
|
||||
(it "logical right shift 13058 >> 5" (logicalRight 5 13058 == 408))
|
||||
(it "negative logical right shift 13058 >> 5" (logicalRight 5 (-13058) == 576460752303423079))
|
||||
(it "arithmetic right shift 13058 >> 5" (arithmeticRight 5 13058 == 408))
|
||||
(it "negative arithmetic right shift 13058 >> 5" (arithmeticRight 5 (-13058) == -409))
|
||||
(it "left shift 10754 << 4" (left 4 10754 == 172064))
|
||||
(it "negative left shift 10754 << 4" (left 4 (-10754) == -172064))
|
||||
(it "logical right shift 10754 >> 4" (logicalRight 4 10754 == 672))
|
||||
(it "negative logical right shift 10754 >> 4" (logicalRight 4 (-10754) == 1152921504606846303))
|
||||
(it "arithmetic right shift 10754 >> 4" (arithmeticRight 4 10754 == 672))
|
||||
(it "negative arithmetic right shift 10754 >> 4" (arithmeticRight 4 (-10754) == -673))
|
||||
(it "left shift 22538 << 3" (left 3 22538 == 180304))
|
||||
(it "negative left shift 22538 << 3" (left 3 (-22538) == -180304))
|
||||
(it "logical right shift 22538 >> 3" (logicalRight 3 22538 == 2817))
|
||||
(it "negative logical right shift 22538 >> 3" (logicalRight 3 (-22538) == 2305843009213691134))
|
||||
(it "arithmetic right shift 22538 >> 3" (arithmeticRight 3 22538 == 2817))
|
||||
(it "negative arithmetic right shift 22538 >> 3" (arithmeticRight 3 (-22538) == -2818))
|
||||
(it "left shift 1792 << 2" (left 2 1792 == 7168))
|
||||
(it "negative left shift 1792 << 2" (left 2 (-1792) == -7168))
|
||||
(it "logical right shift 1792 >> 2" (logicalRight 2 1792 == 448))
|
||||
(it "negative logical right shift 1792 >> 2" (logicalRight 2 (-1792) == 4611686018427387456))
|
||||
(it "arithmetic right shift 1792 >> 2" (arithmeticRight 2 1792 == 448))
|
||||
(it "negative arithmetic right shift 1792 >> 2" (arithmeticRight 2 (-1792) == -448))
|
||||
(it "left shift 29700 << 1" (left 1 29700 == 59400))
|
||||
(it "negative left shift 29700 << 1" (left 1 (-29700) == -59400))
|
||||
(it "logical right shift 29700 >> 1" (logicalRight 1 29700 == 14850))
|
||||
(it "negative logical right shift 29700 >> 1" (logicalRight 1 (-29700) == 9223372036854760958))
|
||||
(it "arithmetic right shift 29700 >> 1" (arithmeticRight 1 29700 == 14850))
|
||||
(it "negative arithmetic right shift 29700 >> 1" (arithmeticRight 1 (-29700) == -14850))
|
||||
(it "left shift 21068 << 0" (left 0 21068 == 21068))
|
||||
(it "negative left shift 21068 << 0" (left 0 (-21068) == -21068))
|
||||
(it "logical right shift 21068 >> 0" (logicalRight 0 21068 == 21068))
|
||||
(it "negative logical right shift 21068 >> 0" (logicalRight 0 (-21068) == -21068))
|
||||
(it "arithmetic right shift 21068 >> 0" (arithmeticRight 0 21068 == 21068))
|
||||
(it "negative arithmetic right shift 21068 >> 0" (arithmeticRight 0 (-21068) == -21068))
|
||||
(it "arithmetic right shift -1 >> 32" (arithmeticRight 32 (-1) == (-1)))
|
||||
(it "arithmetic right shift -1 >> 102" (arithmeticRight 102 (-1) == (-1)))
|
||||
])
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue