Skip to content

Commit 00dcd46

Browse files
Merge pull request #4 from 99linesofcode/formatting-and-linting
Formatting and Linting
2 parents 9761599 + eebeb6b commit 00dcd46

File tree

9 files changed

+3110
-2455
lines changed

9 files changed

+3110
-2455
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_size = 2
9+
indent_style = space
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.vale.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MinAlertLevel = suggestion
2+
3+
Packages = Google, proselint, alex
4+
5+
[*.{md}]
6+
BasedOnStyles = Vale, Google, proselint, alex
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { defineConfig } from 'vitepress'
1+
import { defineConfig } from 'vitepress';
22

33
// https://vitepress.dev/reference/site-config
44
export default defineConfig({
55
lang: 'en-US',
6-
title: "99linesofcode",
7-
description: "A collection of thoughts, ideas and code I felt were worth sharing",
6+
title: '99linesofcode',
7+
description: 'A collection of thoughts, ideas and code I felt were worth sharing',
88
lastUpdated: false,
99
themeConfig: {
1010
siteTitle: '99linesofcode',
@@ -17,14 +17,14 @@ export default defineConfig({
1717

1818
footer: {
1919
message: 'Except where otherwise noted, content on this site is released into the public domain under a Creative Commons Zero license.',
20-
copyright: 'Copyleft © 2024 - present Jordy Schreuders'
20+
copyright: 'Copyleft © 2024 - present Jordy Schreuders',
2121
},
2222

2323
socialLinks: [
24-
{ icon: 'github', link: 'https://github.com/99linesofcode' }
25-
]
24+
{ icon: 'github', link: 'https://github.com/99linesofcode' },
25+
],
2626
},
2727
sitemap: {
28-
hostname: 'https://99linesofcode.nl'
29-
}
30-
})
28+
hostname: 'https://99linesofcode.nl',
29+
},
30+
});

articles/how-i-would-learn-nix-if-i-could-do-it-again.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,41 @@ prev:
88

99
# NixOS and Home Manager
1010

11-
If declaratively defining your user environment, hell, your complete operating system, sounds like a joy to you, then Nix is the tool for you. While I could go at length about what nix is™ or go off on a tangent about how poorly documented™ it is, many have gone before me. If that is the kind of content you are looking for then this is not the article for you. I'll only briefly touch on those subjects before taking you along for a ride, after which I hope you will be able to take the wheel and ride off into the sunset by yourself. Albeit with a sidecar or a pair of training wheels.
11+
If declaratively defining your complete operating system and user environment sounds like a joy to you, then Nix is the tool for you. There is a bit of a learning curve but in this blog post I'll try to make that as smooth as possible for you. Lets go for a ride, a learning how to learn, after which you'll be able to take the wheel and ride off into the sunset by yourself. Albeit with a sidecar or a small set of training wheels.
1212

13-
## What is this Nix you speak of?
13+
## What's this Nix you speak of?
1414

15-
If you are reading this then chances are you are somewhat familiar but struggling to find your way around the ecosystem. On the off chance that you stumbled upon my blog some other way, I will briefly go over the basics:
15+
If you are reading this then chances are you are somewhat familiar but struggling to find your way around the ecosystem. On the off chance that you stumbled upon this blog some other way, I'll briefly go over the basics:
1616

17-
In a nutshell, Nix is a deployment system dreamed up by Eelco Dolstra et al. back in 2004. It was created to deal with some of the issues that arise when distributing and building software across different machines and operating environments.
17+
In summary, Nix is a deployment system dreamed up by Eelco Dolstra et al. back in 2004 to deal with some of the issues that arise when distributing and building software across different machines and operating environments.
1818

19-
It's a tool and functional programming language used to package up software into what Nix calls `derivations`. A derivation is a higher order package that bundles everything that is required to idempotently build a piece of software. If you want to learn more about the issues Nix set out to solve and how it works at this particular layer of the cake, I would recommend you give [the abstract of their master thesis](https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf) a read.
19+
It's a tool and functional programming language used to package up software into what Nix calls `derivations`. A derivation is a higher order package that bundles everything that's required to purely build a piece of software. If you want to learn more about the issues Nix set out to solve and how it works at this particular layer of the cake, I highly recommend that you read through [the abstract of their master thesis](https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf).
2020

21-
What often confuses newcomers is that there is also a Nix based Linux distribution aptly named NixOS. What Nix does, that is building, packaging and distribution of software is essentially all that is needed for and handled by your average bare metal Linux distribution. That someone would eventually come along and package those derivations and modules up into a Linux installer was only a matter of time.
21+
What often confuses newcomers is that there is also a Nix based Linux distribution aptly named NixOS. Nix builds, packages, and distributes software which is essentially everything needed for and handled by your average bare metal Linux distribution. That someone would eventually come along and package those derivations and modules up into a handy Linux installer was only a matter of time.
2222

23-
## Looking for a Quick Fix?
23+
## Looking for a quick fix?
2424

25-
The way Nix works is a bit of a paradigm shift and that's one of the reasons people have a hard time getting into it. Another is the somewhat abysmal state of its documentation. While attempts are on the way to improve upon that, information on how Nix works is still scattered across different websites and wikipedia pages. For those of you with shorter attention spans, these are the resources I will recommend you go through in this article:
25+
The way Nix works is a bit of a paradigm shift and that's one of the reasons people have a hard time getting into it. Another is the somewhat abysmal state of its documentation. While attempts are on the way to improve upon that, information on how Nix works is still scattered across different websites and Wikipedia pages. For those of you with shorter attention spans, these are the resources I'll recommend you go through in this article. Don't bother with other websites:
2626

27-
1. https://nix.dev - Take your first steps here. Don't get lost on Nix Pills or some other obscure website.
28-
1. https://nix.dev/manual/nix - For when you want to dive deeper.
29-
1. https://nixos.org/manual/nixos/stable - For those who want to run NixOS.
30-
1. https://nix-community.github.io/home-manager - For your cross platform dotfiles.
31-
1. https://mynixos.com - For finding existing packages and their configuration options.
32-
1. https://github.com/NixOS/nixpkgs - The Nix package repository where the work on all derivations is done.
33-
1. https://wiki.nixos.org/wiki/NixOS_Wiki - The official wiki (sadly sometimes still outdated compared to the community maintained wiki)
27+
1. <https://nix.dev> - Take your first steps here. Don't get lost on Nix Pills or some other obscure website.
28+
1. <https://nix.dev/manual/nix> - For when you want to dig deeper.
29+
1. <https://nixos.org/manual/nixos/stable> - For those who want to run NixOS.
30+
1. <https://nix-community.github.io/home-manager> - For managing your user environment separately.
31+
1. <https://mynixos.com> - For finding existing packages and their configuration options.
32+
1. <https://github.com/NixOS/nixpkgs> - The Nix package repository where the work on all derivations takes place.
33+
1. <https://wiki.nixos.org/wiki/NixOS_Wiki> - The official wiki
34+
35+
Check these sources first, then consider alternatives such as the community maintained Wikipedia (which is in the process of being phased out).
3436

3537
## A four-step plan to learning Nix
3638

3739
### Learn to read the syntax
3840

39-
It's a lot and you will want to take a methodical approach to learning. If you are just starting out I would advise against diving deep into Nix shells or the way packaging and building derivations work. It's valuable knowledge but at this stage it's more important that you are able to read the language itself. Start by going over the [language basics](https://nix.dev/tutorials/nix-language) so you have an idea of what it is you are looking at when writing your first `configuration.nix` or `flake.nix`.
41+
It's a lot and you'll want to take a methodical approach to learning. If you are just starting out avoid diving deep into Nix shells or the way packaging and building derivations work. It's valuable knowledge but at this stage it's more important that you are able to read the language itself. Start by going over the [language basics](https://nix.dev/tutorials/nix-language) so you have an idea of what it's you are looking at when writing your first `configuration.nix` or `flake.nix`.
42+
43+
### Go over the configuration syntax and module system
4044

41-
### Go over the Configuration Syntax and Module System
42-
Many of the examples or repositories you will be referencing and drawing inspiration from can be a bit intimidating and will often contain custom code, use nix flakes or depend on other libraries to extend functionality. If you don't understand how Nix ties all of this together you will quickly get lost. Spend some time learning about the [configuration syntax](https://nixos.org/manual/nixos/stable/#sec-configuration-syntax) and [the Nix module system](https://nix.dev/tutorials/module-system).
45+
Many of the examples or repositories you will be referencing and drawing inspiration from can be a bit intimidating and will often contain custom code, use nix flakes or depend on other libraries to extend it's functionalities. If you don't understand how Nix ties all of this together you'll quickly get lost. Spend some time learning about the [configuration syntax](https://nixos.org/manual/nixos/stable/#sec-configuration-syntax) and [the Nix module system](https://nix.dev/tutorials/module-system).
4346

4447
In summary, assuming you understand what an attribute set is, Nix modules consist of functions taking a single attribute set as a parameter and returning an attribute set adhering to a specific schema:
4548

@@ -54,12 +57,14 @@ In summary, assuming you understand what an attribute set is, Nix modules consis
5457
};
5558
}
5659
```
60+
5761
### Use Nix to configure a well-known application
58-
Since Nix has the largest package repository in the world, chances are your favorite piece of software is already packaged up into a derivation and actively being maintained. See if you can find it by searching for it on [MyNixOS](https://mynixos.com). As an example, I will use my favorite shell, Zsh:
62+
63+
Since Nix has the largest package repository in the world, chances are your favorite piece of software is already packaged up into a derivation and actively being maintained. See if you can find it by searching for it on [MyNixOS](https://mynixos.com). As an example, lets take a look at the Unix shell, Zsh:
5964

6065
![MyNixOS Zsh search result](../images/mynixos-zsh-search-result.png)
6166

62-
In the screenshot above you can see that Zsh exists as a derivation (`nixpkgs/package/zsh`) in the nixpkgs package repository as well as a Nix Module (`nixpkgs/option/programs.zsh`). Oftentimes there already exists a Nix module to simplify configuring the application and abstracting away any complexities that may be involved with it. To use the Zsh module we can simply enable it as follows:
67+
In the screenshot above you can see that Zsh exists as a derivation (`nixpkgs/package/zsh`) as well as a Nix Module (`nixpkgs/option/programs.zsh`). Oftentimes a Nix module already exists to simplify configuring the application and abstracting away any complexities that may be involved with it. To use the Zsh module lets enable it as follows:
6368

6469
```nix
6570
{...}:
@@ -86,18 +91,18 @@ Clicking through MyNixOS provides additional information about the `enable` modu
8691

8792
![MyNixOS Zsh module option](../images/mynixos-zsh-module-enable-details.png)
8893

89-
Once you feel you are somewhat comfortable with the Nix language and you understand how the module system works, you should definitely take a look at some of these module files in the nixpkgs repository. You'll likely find them surprisingly straightforward to understand. Especially when you have configured a couple of applications and built a module yourself!
94+
Once you feel you are somewhat comfortable with the Nix language and you understand how the module system works, you should definitely take a look at some of these module files in the `nixpkgs` repository. You'll likely find them surprisingly straightforward to understand. Especially when you have configured a couple of applications and built a module yourself.
9095

9196
### Learn how to package an application
9297

93-
Go ahead and dive into the [First Steps](https://nix.dev/tutorials/first-steps/) learning about nix shells and [packaging existing software with Nix](https://nix.dev/tutorials/packaging-existing-software). Once you are done working through those guides you should find that almost all the puzzle pieces have fallen into place.
98+
Go ahead and read through the [First Steps](https://nix.dev/tutorials/first-steps/) learning about nix shells and [packaging existing software with Nix](https://nix.dev/tutorials/packaging-existing-software). Once you have worked through those guides you should find that almost all the puzzle pieces have naturally fallen into place.
9499

95100
## Home Manager
96101

97-
Home Manager is a tool created by the Nix community to specifically manage your user's home directory, separately from your OS. It provides an additional set of Nix modules specifically dedicated to managing your user programs, configuration files, environment variables, etc. At its core, it's just Nix, built on top of Nix and the very module system you have since become familiar with. It's just wired up a little differently. For more information, [check out the official documentation](https://nix-community.github.io/home-manager).
102+
Home Manager is a tool created by the Nix community to specifically manage your user's home directory, separately from your OS. It provides an additional set of Nix modules specifically dedicated to managing your user programs, configuration files, environment variables, etc. At its core, it's just Nix, built on top of Nix and the module system you have since become familiar with. It's just wired up a little differently. For more information, [check out the official documentation](https://nix-community.github.io/home-manager).
98103

99104
## Still here? Impressive
100105

101-
That's it. You should now be able to take your bike off that kickstand and go for a ride all on your own. If you are craving some more inspiration, you are welcome to take a look at my humble [NixOS](https://github.com/99linesofcode/nixos-config) and [Home Manager](https://github.com/99linesofcode/home-manager) repositories. They are heavily inspired by the work of others and still very much a work in progress but perhaps you can find some use for them.
106+
That's it. You should now be able to take your bike off that kickstand and go for a ride all on your own. If you are craving some more inspiration, you are welcome to take a look at my humble [NixOS](https://github.com/99linesofcode/nixos-config) and [Home Manager](https://github.com/99linesofcode/home-manager) repositories. They're heavily inspired by the work of others and still a work in progress but perhaps you can find some use for them.
102107

103108
Happy tinkering!

eslint.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import stylistic from '@stylistic/eslint-plugin';
2+
3+
export default [
4+
stylistic.configs.recommended,
5+
{
6+
files: [
7+
'**/*.js',
8+
'**/*.mjs',
9+
'**/*.ts',
10+
],
11+
rules: {
12+
'@stylistic/array-bracket-newline': [
13+
'error',
14+
'always',
15+
],
16+
'@stylistic/array-bracket-spacing': [
17+
'error',
18+
'always',
19+
],
20+
'@stylistic/array-element-newline': [
21+
'error',
22+
'always',
23+
],
24+
'@stylistic/comma-dangle': [
25+
'error',
26+
'always-multiline',
27+
],
28+
'@stylistic/indent': [
29+
'error',
30+
2,
31+
],
32+
'@stylistic/semi': [
33+
'error',
34+
'always',
35+
],
36+
'@stylistic/quotes': [
37+
'error',
38+
'single',
39+
],
40+
},
41+
},
42+
];

flake.nix

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,43 @@
2424
formatter = forEachSystem (s: nixpkgs.legacyPackages.${s}.nixfmt-rfc-style);
2525

2626
devShells = forEachSystem (
27-
s: with nixpkgs.legacyPackages.${s}; {
28-
default = mkShell {
29-
packages = [
30-
nodePackages.nodejs
27+
system:
28+
let
29+
pkgs = import nixpkgs {
30+
inherit system;
31+
overlays = [
32+
# (final: prev: {
33+
# nodejs = prev.nodejs_22;
34+
# })
3135
];
36+
};
37+
38+
# buildNodeJs = pkgs.callPackage "${nixpkgs}/pkgs/development/web/nodejs/nodejs.nix" {
39+
# python = pkgs.python3;
40+
# };
41+
42+
# nodejs = buildNodeJs {
43+
# enableNpm = false;
44+
# version = "22.14.0";
45+
# sha256 = "sha256-xgmUa/eTtVx5VMJlgnYICNVMFhhdecsvuIBl5S3iGRQ=";
46+
# };
47+
in
48+
{
49+
default = pkgs.mkShell {
50+
# buildInputs = with pkgs; [
51+
# nodejs
52+
# ];
53+
54+
packages = with pkgs; [
55+
nodejs
56+
nodePackages.pnpm
57+
58+
vale # prose linter
59+
valeStyles.alex
60+
valeStyles.google
61+
valeStyles.proselint
62+
];
63+
3264
shellHook = ''
3365
export PATH="$PWD/node_modules/.bin/:$PATH"
3466
'';

0 commit comments

Comments
 (0)