Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NixOS should set programs.less.lessopen.default = null #309599

Open
sarcasticadmin opened this issue May 6, 2024 · 0 comments · May be fixed by #316979
Open

NixOS should set programs.less.lessopen.default = null #309599

sarcasticadmin opened this issue May 6, 2024 · 0 comments · May be fixed by #316979
Labels
0.kind: enhancement 6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform 9.needs: module (update)

Comments

@sarcasticadmin
Copy link
Member

sarcasticadmin commented May 6, 2024

Issue description

When using the default pager less in NixOS, it is set to use a preprocessor calling lesspipe. lesspipe provides the following enhancements to less thus modifying less' default behavior. This behavior as a NixOS default seems unexpected.

The NixOS minimal profile already has programs.less.lessopen = mkDefault null;: 8dfe8e4

Im proposing removing any preprocessing in less by default and set programs.less.lessopen.default = null;

Steps to reproduce

$ echo $LESSOPEN # shows that less preprocessor is set
|/nix/store/2hh93jad9hlhgy2sqj4rfzsjj7c5pdf5-lesspipe-2.10/bin/lesspipe.sh %s
$ cat << EOF > example.json
{
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}
EOF
$ less example.json | cat
==> (lesspipe 2.10) append : to filename to view the original json file
{
  "glossary": {
    "title": "example glossary",
    "GlossDiv": {
      "title": "S",
      "GlossList": {
        "GlossEntry": {
          "ID": "SGML",
          "SortAs": "SGML",
          "GlossTerm": "Standard Generalized Markup Language",
          "Acronym": "SGML",
          "Abbrev": "ISO 8879:1986",
          "GlossDef": {
            "para": "A meta-markup language, used to create markup languages such as DocBook.",
            "GlossSeeAlso": [
              "GML",
              "XML"
            ]
          },
          "GlossSee": "markup"
        }
      }
    }
  }
}

Note the output off less: ==> (lesspipe 2.10) append : to filename to view the original json file

You can disable the preprocessor by setting the following in your nix Configuration:

programs.less.lessopen = lib.mkDefault null;

I also had to log out of my existing session (i3) to get my profile to update after a nixos-rebuild switch. After I can confirm LESSOPEN is not set in the environment:

$ echo $LESSOPEN

$

Confirm output with less:

$ less example.json | cat
{
    "glossary": {
        "title": "example glossary",
                "GlossDiv": {
            "title": "S",
                        "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                                        "SortAs": "SGML",
                                        "GlossTerm": "Standard Generalized Markup Language",
                                        "Acronym": "SGML",
                                        "Abbrev": "ISO 8879:1986",
                                        "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                                                "GlossSeeAlso": ["GML", "XML"]
                    },
                                        "GlossSee": "markup"
                }
            }
        }
    }
}

Output is now the default of less without the preprocessor.

Technical details

$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/vm49ygzdh61j1r39l8ikb29icwljlymn-nix-info
copying path '/nix/store/vm49ygzdh61j1r39l8ikb29icwljlymn-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.26, NixOS, 23.11 (Tapir), 23.11.20240411.51651a5`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-22.05.3300.82379884b2e"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@tomodachi94 tomodachi94 added 0.kind: enhancement 9.needs: module (update) 6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform labels May 13, 2024
@sarcasticadmin sarcasticadmin linked a pull request Jun 3, 2024 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement 6.topic: portability General portability concerns, not specific to cross-compilation or a specific platform 9.needs: module (update)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants